无法检测测试类的默认资源位置:类路径资源不存在

时间:2014-05-12 14:02:02

标签: java spring maven jenkins

我在jenkins中运行maven build时遇到了一些问题。它试图运行我的集成测试但是,继续抛出这个错误:

 java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to detect defaults, and no ApplicationContextInitializers were declared for context configuration [ContextConfigurationAttributes@2d10dd87 declaringClass = 'com.xxxx.api.services.MessageServiceImplIntegrationTest', locations = '{}', classes = '{}', inheritLocations = true, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader']

请参阅完整堆栈跟踪link的链接。

1 个答案:

答案 0 :(得分:3)

错误与这部分日志有关:

INFO : org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.xxxx.api.services.MessageServiceImplIntegrationTest]: class path resource [com/xxxx/api/services/MessageServiceImplIntegrationTest-context.xml] does not exist
INFO : org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.xxxx.api.services.MessageServiceImplIntegrationTest]: MessageServiceImplIntegrationTest does not declare any static, non-private, non-final, inner classes annotated with @Configuration.

基本上,您的测试类没有可用于构建应用程序上下文的配置部分(xml或@Configuration)。

有关使用xml进行测试配置的信息,请参阅this link;有关@Configuration注释的配置,请参见this one