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规范定义。

 

相关文章:

  • 2021-07-13
  • 2021-07-29
  • 2021-04-13
  • 2021-10-27
  • 2022-12-23
猜你喜欢
  • 2021-11-22
  • 2021-05-31
  • 2021-06-29
  • 2021-08-11
  • 2021-04-25
  • 2021-08-27
  • 2021-06-04
相关资源
相似解决方案