gpt4 book ai didi

java - 无法检测到测试类 : class path resource does not exist 的默认资源位置

转载 作者:行者123 更新时间:2023-11-29 07:48:10 24 4
gpt4 key购买 nike

我在 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 .

最佳答案

错误与这部分日志有关:

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)。

参见 this link用于使用 xml 和 this one 进行测试配置用于使用 @Configuration 注释进行配置。

关于java - 无法检测到测试类 : class path resource does not exist 的默认资源位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23611132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com