错误分析
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
原因是测试类在测试包test下的包名和类路径java下的包名不一致导致的
解决1
修改包名一致即可

解决 2
参考https://blog.youkuaiyun.com/wwwwwww31311/article/details/115461920
在注解上加上@SpringBootTest(classes = xxx.class),来告诉springboot这是一个独立的测试类
博客分析了Java中Spring Boot测试时出现的错误,即测试类在测试包test下的包名和类路径java下的包名不一致,导致出现Unable to find a @SpringBootConfiguration的异常。并给出两种解决办法,一是修改包名一致,二是在注解上加@SpringBootTest(classes = xxx.class)。
3114

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



