如题,最近在做项目的过程中发现

​SpringBootTest​​​测试类中的​​BrandService​​ 无法注入。

在idea中,​​brandService​​是爆红的。

SpringBoot测试类:Could not autowire. No beans of ‘BrandService‘ type found_测试类

解决方案

​spring boot测试类​​​ 包名与​​main​​下application.class启动类的包名默认要一致。

即下图中的两个包名都是​​com.honyelchak.gulimall.product​

SpringBoot测试类:Could not autowire. No beans of ‘BrandService‘ type found_autowired_02