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

Dea*_*ean 1 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']
Run Code Online (Sandbox Code Playgroud)

有关完整的堆栈跟踪链接,请参见链接

And*_*fan 5

错误与日志的此部分有关:

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.
Run Code Online (Sandbox Code Playgroud)

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

请参阅此链接以XML为测试配置和这个与配置@Configuration注解。