SpringBoot Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration

蔚落 2022-04-24 07:22 393阅读 0赞

SpringBoot Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration

@SpringBootTest 测试时出现 异常内容:
Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) …

原因:
test 中的测试类的包名和 java 下的包名不一致导致,找不到

解决方法一(建议):

将 test 中的 测试类包名改成和上面一致

解决方法二:

在注解上指定启动类

  1. @SpringBootTest(classes = Application.class))

发表评论

表情:
评论列表 (有 0 条评论,393人围观)

还没有评论,来说两句吧...

相关阅读