首页 > 其他分享 >Spring 测试运行的时候提示 Unable to find a @SpringBootConfiguration 错误

Spring 测试运行的时候提示 Unable to find a @SpringBootConfiguration 错误

时间:2022-10-05 12:33:05浏览次数:77  
标签:测试运行 Spring SpringBootConfiguration Unable 测试 find

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-Test-Error-01

 

问题和解决

这个问题的主要原因是测试的包和项目的包的路径可能不一致。

这将会导致测试没有办法找到有关 Spring 有关的配置。

 

Spring-Test-Error-02

 

对比上面的图,我们就可以看到这个问题。

解决方法就是确定包的路径是一致的,这样 Spring 的测试类可以找到 Spring 有关的配置。

 

https://www.ossez.com/t/spring-unable-to-find-a-springbootconfiguration/14132

标签:测试运行,Spring,SpringBootConfiguration,Unable,测试,find
From: https://www.cnblogs.com/huyuchengus/p/16755384.html

相关文章