小编Ste*_*han的帖子

对于git,如何通过一个命令在子目录中暂存所有更改,包括删除?

我们知道git add .可以立即暂存所有新文件或更改.

但是如果直接删除文件rm command,git add .则不会进行这些修改.

是否有一个有效的命令来暂存所有更改,包括在子目录中删除?

git

3
推荐指数
1
解决办法
139
查看次数

如何在javascript中为最少一个字符编写正则表达式?

我对正则表达式的要求很小,这里我需要至少一个字母,然后是数字和特殊字符。我尝试了以下正则表达式,但没有得到解决方案。

/^[a-zA-Z0-9\-\_\/\s,.]+$/
Run Code Online (Sandbox Code Playgroud)

/^([a-zA-Z0-9]+)$/
Run Code Online (Sandbox Code Playgroud)

javascript regex

3
推荐指数
1
解决办法
1万
查看次数

匹配子字符串但不是异常子字符串

我有一些字符串:

new_account_notification
updated_account_notification
reactivated_account_notification
updated_billing_info_notification
Run Code Online (Sandbox Code Playgroud)

我想匹配这些字符串:

  • 应该包含 account
  • 但不应该包含 reactivated_account
  • 或者应该包含 billing_info

请建议正则表达式来满足这些条件.

ruby regex

3
推荐指数
1
解决办法
69
查看次数

maven - 如何解决此错误:“XXX 的 POM 无效”?

我正在使用 Maven 构建一个简单的项目。我无法构建它,因为缺少传递依赖项,即objenesis 1.0.

我在调试模式下运行 Maven 并收到以下消息:

[DEBUG] =======================================================================
[WARNING] The POM for org.jmock:jmock-junit4:jar:2.6.0 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for org.jmock:jmock-junit4:2.6.0
[ERROR] Invalid packaging for parent POM org.jmock:jmock-parent:2.6.0, must be "pom" but is "jar" @ org.jmock:jmock-parent:2.6.0
...
Run Code Online (Sandbox Code Playgroud)

当我查看 jmock-parent 时,我似乎找不到对 pom 或 jar 类型的引用。

我该如何解决这个问题?

注意:我们使用我们公司的 Nexus 来获取依赖项。


pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Poc</groupId>
<artifactId>Poc</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
</properties>

<dependencies> …
Run Code Online (Sandbox Code Playgroud)

java dependencies jmock maven transitive-dependency

3
推荐指数
1
解决办法
1万
查看次数

无法安装此加载项,因为它似乎已损坏

这是我的示例插件的结构:

我的 Selenium-IDE 结构

这是我构建 XPI 文件的方法:

cd my-addon
C:\Progra~1\7-Zip\7z.exe a -r -y -tzip ../my-addon.xpi *
Run Code Online (Sandbox Code Playgroud)

当我尝试在 Firefox 中加载生成的 xpi 时,出现以下错误:

无法安装此加载项,因为它似乎已损坏。

我错过了什么?

firefox selenium-ide firefox-addon

3
推荐指数
1
解决办法
3892
查看次数

getClass返回什么类型?

这是我的代码:

Set<Class<Event>> s = new HashSet<>();             
Set<Class<? extends Event>> s2 = new HashSet<>();
Event e = new Event();                         

s.add(e.getClass());   // #1
s2.add(e.getClass());  // #2

class Event {
    // ...
}
Run Code Online (Sandbox Code Playgroud)

为什么编译器会在语句中引发错误#1

我正在使用Java 7.

java generics

3
推荐指数
1
解决办法
475
查看次数

使用平衡parantheses在java中拆分字符串

我需要拆分以下字符串((OPERATING_CARRIER ='AB'或OPERATING_CARRIER ='AB'OR(OPERATING_CARRIER ='VA'AND(FLIGHT_NO = 604或FLIGHT_NO = 603)))):

OPERATING_CARRIER='AB'
OPERATING_CARRIER='AB'
OPERATING_CARRIER='VA'
FLIGHT_NO=604
FLIGHT_NO=603
Run Code Online (Sandbox Code Playgroud)

我尝试了下面这段代码

String syntax = "(OPERATING_CARRIER='AB' OR OPERATING_CARRIER='AB' OR     (OPERATING_CARRIER='VA' AND (FLIGHT_NO=604 OR FLIGHT_NO=603)))";
List < String > matchList = new ArrayList < String > ();
Pattern regex = Pattern.compile("\\(([^)]*)\\)");
Matcher regexMatcher = regex.matcher(syntax);
while (regexMatcher.find()) 
{
    matchList.add(regexMatcher.group(1));
    System.out.println(regexMatcher.group(1));
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出为OPERATING_CARRIER ='AB'或OPERATING_CARRIER ='AB'OR(OPERATING_CARRIER ='VA'AND(FLIGHT_NO = 604或FLIGHT_NO = 603)

java regex parsing

3
推荐指数
1
解决办法
68
查看次数

什么是JPQL中的SQL ANY运算符?

鉴于以下Oracle sql查询为PreparedStatement:

SELECT *
FROM my_table
WHERE field1 = 'foo'
and field2 =ANY (substr( ? , 1, 2) || '00000000',
                 substr( ? , 1, 4) || '000000',
                 substr( ? , 1, 6) || '0000',
                 substr( ? , 1, 8) || '00',
                 ?
                )
Run Code Online (Sandbox Code Playgroud)

我想翻译成JPQL查询.阅读JPQL文档,substr变得substringANY保持不变.在JPQL中ANY需要一个子查询.

如何将列表更改为子查询?或者我应该使用IN运算符还是应该生成带有一堆OR条件的JPQL字符串?

Oracle 10gR2
Java 5
JPA 2

java sql oracle hibernate jpa

2
推荐指数
1
解决办法
1593
查看次数

使用JSF从JAR文件中加载属性文件

这是我项目的Maven结构

app
  > common-module
  > webapp-module
  > batch-module
 pom.xml

common-module公开一个Version类.webapp和批处理模块都使用此类.

Version班有一个所谓的独特的静态方法get.它返回项目的全局版本.

全局版本存储在属性文件中.当get从批料模块(一个独立的Java应用程序)调用,属性文件成功加载.

在webapp中,情况有所不同.我创建了一个托管bean VersionBean,允许任何JSF页面调用该get方法.每当我使用以下之一时

FacesContext.getCurrentInstance().getExternalContext()

FacesContext.getCurrentInstance().getExternalContext().getContext()

Thread.currentThread().getClassLoader()
Run Code Online (Sandbox Code Playgroud)

我永远找不到properties.file.

如何从托管bean加载位于jar文件中的属性文件(getResourceAsStream)?

编辑
这是我根据@BalusC和@eljunior的建议提出的解决方案

VersionBean.java

@ManagedBean(eager=true)
@ApplicationScoped
public class VersionBean {
    private String version;
    @PostConstruct
    public void init(){
        version = Version.get();
    }
}
Run Code Online (Sandbox Code Playgroud)

Version.java

public class Version {
    public static String get() {
        InputStream is = Version.class.getResourceAsStream("/version.properties");

        // Read InputStream and return version string ...
    }
}
Run Code Online (Sandbox Code Playgroud)

java jsf

2
推荐指数
1
解决办法
1926
查看次数

这个建筑的名称是什么?

我正在读一个我没写过的代码.我偶然发现了以下声明:

    context.checking(new org.jmock.Expectations() {
        {
            allowing(habilitationManager).hasRole(RoleDtoEnum.ROLE_NEWS);
            will(returnValue(true));
            allowing(habilitationManager).hasRole(RoleDtoEnum.ROLE_STAT);
            will(returnValue(true));
            allowing(habilitationManager).getUser();
            will(returnValue(getUserMock()));
            oneOf(parametreService).getParametre(PPP);
            will(returnValue(getMockPPP()));
        }
    });
Run Code Online (Sandbox Code Playgroud)

据我所知,第二种方法中的方法{ ... }Expectations方法.

  • 但是你怎么称这种代码写作?
  • 特别是你怎么称呼第二个{ ... }

java

2
推荐指数
1
解决办法
116
查看次数