springboot在测试类中测试报错
尝试执行测试

报错信息如下

关键信息
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
无法找到@SpringBootConfiguration,您需要使用@ContextConfiguration或@SpringBootTest(classes=…)与您的测试
原因:测试类的包名和项目包名不一致
项目结构

测试类也应放在com.atguigu包下
更正,有没有test包都行,直接放到com.atguigu包下也行


浙公网安备 33010602011771号