java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Context
问题描述
在运行单元测试报错:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
原因分析:
1. 没有启动类
2. 没有加载到启动类 -无法找到@SpringBootConfiguration
3. 测试类包名,调整到和启动类一致即可。
解决方案:
1. 在@SpringBootTest添加启动类,配置启动类
2. 添加@ContextConfiguration注解,配置启动类
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...