Differences between autowired annotations and resource annotations in spring

Source: Internet
Author: User

1. Different jar packages, autowired is the resource in spring is the JSR-250 specification definition annotation

2. Automatic assembly can be selected when the parameters are different, the specific can see its interface

Resource There are these several configurable , I can only read the name and type, meaning is assembled by name, assembled by type.

The default installation name is assembled. When a bean matching the name cannot be found, it is assembled by type.

If the Name property is specified once, it will only be assembled by name.

If type is specified, an exception is thrown when an assembly is typed, no more than one bean is found, or multiple beans are found

Autowired: default by Type assembly, interface with only one required, by default must require the dependent object must exist, if you want to allow null value, you can set its Required property to false.

Main references for Blogs

http://blog.csdn.net/cycbest/article/details/8015498

Http://www.cnblogs.com/leiOOlei/p/3713779.html

Finally, found that their ability is limited, there may be errors in the essay, ask the Great God to criticize

Differences between autowired annotations and resource annotations in spring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.