@Resoure和@Autowired的区别
时间: 2024-03-23 16:19:01 浏览: 66
@Resoure和@Autowired都是用于依赖注入的注解,但它们有一些区别。@Autowired是Spring框架的注解,而@Resource是JSR 250规范中定义的注解,Spring对该规范提供了支持。
区别一:匹配方式
@Autowired是根据类型(type)进行依赖匹配,即根据被注入对象的类型来查找相应的依赖对象;而@Resource可以根据名称(name<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [@Resource和@Autowired的区别](https://blog.csdn.net/mrxutada/article/details/118811930)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [【Java面试】@Resource 和 @Autowired 的区别](https://blog.csdn.net/weixin_45566993/article/details/125424934)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文