springboot项目test类中的@Autowire无法自动注入

expected at least 1 bean which qualifies as autowire candidate

原因:
启动类与测试类同名
@SpringBootTest注解中的ApplicationMain.class无法识别是哪个类
更改其中一个类名即可

另外注意测试类和启动类需要在同一级(包)

在这里插入图片描述

发布了29 篇原创文章 · 获赞 0 · 访问量 1195

猜你喜欢

转载自blog.csdn.net/flipped___/article/details/104351545
今日推荐