springboot test: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or

错误信息:

java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

原因

因为自己修改了main下面的包名,导致test下面的包名跟main下面不一致,导致junit无法自动@Autowired DI注入

将红框中两个包名修改为一致,问题即可解决

posted @ 2022-10-04 00:13  IT情深  阅读(72)  评论(0)    收藏  举报