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

Java 无法检测测试类的默认资源位置:类路径资源不存在,java,spring,maven,jenkins,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

我在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']

有关完整堆栈跟踪,请参阅链接。

错误与这部分日志有关:

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的测试配置和使用
@configuration
注释的配置,请参阅。

这不是真的,但是,我的错误是没有显示我的实际测试,请参阅链接。我有一个MessageServiceImplictionIntegrationTest-context.xml,它与spring文档所说的测试位于同一位置(如果e@ContextConfiguration的“位置”中没有包含一个),它将使用测试名称并附加“-context.xml”从类路径加载测试。当我从eclipse运行Maven测试时,它被找到,并且测试通过。当我将它部署到jenkins时,它会运行,然后它会抱怨找不到该文件。您没有提到它与Maven test一起工作。嗯,那么Jenkins的设置有问题,可能是一些类路径配置,而不是Spring。我认为更可能是类路径,但是,我如何能够检查..特别是Jenkins,如果可能的话还是STS。jenkins或maven使用什么文件来确定类路径?我想这个文件可能在我的.gitIgnore中,没有提交给jenkins。