The experience of constructing injection with XML configuration in spring

Source: Internet
Author: User

If the <constructor-arg> attribute is ref , the parameter order is ignored in spring when constructing injection with XML configuration

<constructor-arg ref= "Killer"/>

<constructor-arg ref= "User"/>

And

<constructor-arg ref= "User"/>

<constructor-arg ref= "Killer"/>

The same effect (assuming that there is only one construction method, the parameter order is (Killer K, User us), these 2 kinds of notation are OK; Of course, if there is a second construction method, the parameter order is (User us, Killer K), then the second one will match the second construction method);

However, if the <constructor-arg> attribute has value , the parameter order must be considered

<constructor-arg value= "2"/>

<constructor-arg ref= "Killer"/>

And

<constructor-arg ref= "Killer"/>

<constructor-arg value= "2"/>
must correspond to 2 different construction methods respectively

The experience of constructing injection with XML configuration 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.