JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

@Autowired和@Resource

发布时间 2023-03-29 22:12:07作者: 土木转行的人才

1.区别

@Resource

根据 name 查找已知确定资源,查询不到再根据 type 查找已知确定资源

@Autowired

根据 type 搜索范围内的资源,查询不到再根据 name 搜索范围内的资源

2.使用范围推荐 @Autowired

如下只有@Autowired适用:

@Autowired
List<UserService> list

3.参考

https://blog.csdn.net/xhbzl/article/details/126765893

    本栏目推荐文章
  • java jdk @Resource注入
  • 解决前后端的跨域问题:Access to XMLHttpRequest at '**' from origin '**' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  • No 'Access-Control-Allow-Origin' header is present on the requested resource', 跨域访问的解决方法
  • @Autowire和@Resource的区别
  • 【五期李伟平】CCF-A(MobiCom'18 Session EdgeTech'18)A Game-Theoretic Approach to Multi-Objective Resource Sharing and Allocation in Mobile Edge Clouds
  • Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING。
  • springboot项目Mapper注入失败:@org.springframework.beans.factory.annotation.Autowired(required=true)
  • C语言全局变量的extern+typedef函数指针+uvm_queue/pool/config_db/resource_db/barrier+接口设计分层+PCIe电气接口
  • docker 命令 报错device or resource busy
  • @Autowired和@Resource区别
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们