5. Resource annotation parsing, 5. resource Annotation

Source: Internet
Author: User

5. Resource annotation parsing, 5. resource Annotation

Resource can be used in two scenarios:

1. Resource

When a Resource is not followed by a parameter, it is directed to applicationContext Based on the attribute name it is annotated. in the xml file, check whether the bean id matches it. If yes, assign the corresponding class to it,

If no value is available, it is matched to the configuration file based on the annotation attribute type. If yes, it is assigned a value. If no value exists, an error is returned.

2. Resource (name = "")

If the Resource is followed by a name parameter, it is directly matched with the bean id based on the name value. If yes, the value is assigned. If no, an error is returned.

 

Resource is a java Native annotation, and the spring framework also provides Autowired and Qualifer annotations,

Autowired matches by type, while Qualifer matches by attribute name.

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.