Spring 进行测试的时候提示的错误信息如下:
SEVERE: Caught exception while closing extension context: org.junit.jupiter.engine.descriptor.JupiterEngineExtensionContext@c63c11ed
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
这个问题的主要原因是测试的包和项目的包的路径可能不一致。
这将会导致测试没有办法找到有关 Spring 有关的配置。
对比上面的图,我们就可以看到这个问题。
解决方法就是确定包的路径是一致的,这样 Spring 的测试类可以找到 Spring 有关的配置。
https://www.ossez.com/t/spring-unable-to-find-a-springbootconfiguration/14132
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。