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注入

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

猜你喜欢

转载自blog.csdn.net/wh445306/article/details/112166040