Could not autowire. No beans of 'BookService' type found.

Idea的SpringBoot工程里遇到Could not autowire. No beans of ‘BookService’ type found。

解决办法: 换成@Resource

spring中注解@Resource 与@Autowire 区别
1.@Autowired按byType自动注入。

2.@Resource默认按byName自动注入。

但是@Resource有两个属性是比较重要的,分是name和type;

如果使用name属性,则使用byName的自动注入策略,而使用type属性时则使用byType自动注入策略;

3.@Autowired是spring自己定义的注解,@Resource是J2EE的,由JSR-250规范定义。

原文地址:https://www.cnblogs.com/mingforyou/p/14612450.html