单元测试报错:unable to find a @SpringBootConfiguration


完整异常:

Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
无法找到@SpringBootConfiguration,您需要在测试中使用@ContextConfiguration或@SpringBootTest(classes=…)

问题产生的几种情况:

1.启动类 或者 程序入口类的包名和测试类所在包名不一致
例如:
启动类:com.leyou下的启动类
测试类:com.leyou.test下的测试类,“.test”多余

2.程序入口类忘了添加:SpringBootApplication注解

解决:

包名一致


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM