- 在单元测试的时候:
报:java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
解决:
1.你要有启动类,这个一般没人犯错;
2.junit他不知道你的启动类在哪;
但是我们看提示:
所以,有博主说应该吧test和启动类放在一起,但是,这不破坏了maven的结构啦嘛
我们的test测试相关类就应该放在test里
我们看提示他有个参数:
@SpringBootTest(classes=...)
这不正是让您给提示个路径嘛
把启动类的.class放进去,哎嘿:
虽然null吧,但是咱成了!!好,继续写bug,啊不,改代码,,,啊不,写代码(ಥ_ಥ)