记录使用SpringBoot测试类时遇到的两个问题
1.java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
异常信息
问题出现的原因有两个
1.需要将测试类所在的包名,改成与其他分支的包名,如下图(参考)
2.在测试类中的@SpringBootTest注解中的calsses属性值等于启动类.class,用来加载启动类,如图所示(参考)
2.java.lang.IllegalStateException: Shutdown in progress
异常信息
问题原因:测试结束Shutdown in progress释放资源
解决方案
在测试方法的结尾加上一个条件未true的while循环即可