Use of @Autowired

Source: Internet
Author: User

The following code needs to be added to the 1.benas XML file

<bean
class= "Org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>

The 2.beans node has a property that needs to be set default-autowire= "Bytype", that is, whether the automatic rig is based on the configured bean type lookup or otherwise, such as the Bean's name

With the above settings, the @autowired annotations on the properties (fields) of the class can be used to automate Assembly.

You can also delete the GET, set method for this property. Because automatic assembly uses reflection to automatically set values for you.

As shown in the delegation.

Let the properties of a class automatically assemble as long as it declares

@Autowired
Private Ilicencekeydao DAO = null;

Use of @Autowired

Related Article

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.