java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
at org.springframework.util.Assert.state(Assert.java:73)
at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.getOrFindConfigurationClasses(SpringBootTestContextBootstrapper.java:240)
at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.processMergedContextConfiguration(SpringBootTestContextBootstrapper.java:153)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:395)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildDefaultMergedContextConfiguration(AbstractTestContextBootstrapper.java:312)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTest
springboot单元测试总是报错 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you
最新推荐文章于 2024-08-09 16:49:01 发布
在执行SpringBoot单元测试时遇到了`java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration`错误。该错误通常由于缺少正确的配置类或未正确使用`@ContextConfiguration`或`@SpringBootTest(classes=…)`注解导致。错误堆栈显示了从`Assert.state`到`JUnit4IdeaTestRunner.startRunnerWithArgs`的调用流程,表明问题可能出在测试框架与Spring Boot配置的集成上。
摘要由CSDN通过智能技术生成