
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
主要问题没有找到对应的启动类
配置附加到应用程序类
@RunWith(SpringRunner.class)
@SpringBootTest(classes= AdminApplication.class) //指定对应的启动类就可以了
public abstract class BaseTest {
protected final Logger logger= LoggerFactory.getLogger(this.getClass());
}
就可以解决
本文详细解析了在使用Spring Boot进行单元测试时遇到的java.lang.IllegalStateException异常,主要原因是未能正确配置启动类。通过在测试类中使用@SpringBootTest注解并指定启动类,可以有效避免这一问题。
3003

被折叠的 条评论
为什么被折叠?



