Java Spring / Maven LogFactory错误

时间:2014-01-27 21:34:50

标签: java spring web-services maven-2

我正在尝试在Maven / Spring项目上运行JUnit,并正在使用Web服务客户端(axis2)进行测试。

以下是有缺陷的Web服务客户端调用:

ProServiceLocator locator = new ProServiceLocator(); // CRASH
proServiceEndpoint = locator.getProServicePort();

这是错误:

java.lang.ExceptionInInitializerError
Caused by: org.apache.commons.discovery.DiscoveryException: No implementation defined for org.apache.commons.logging.LogFactory

这是我的子项目的POM:

...
<dependency>
        <artifactId>commons-logging</artifactId>
        <groupId>commons-logging</groupId>
        <version>${commons-logging.version}</version>
    </dependency>

帮助?

1 个答案:

答案 0 :(得分:3)

将下面的代码放在我的空“* Test.java”文件中,这样就可以了!

@BeforeClass  
public static void beforeClass() {  
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");  
    System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.LogFactoryImpl");  
}