Spring (3.2.3)-Beans (5): Injection of collection properties

Source: Internet
Author: User

If a Bean's properties are collections, you can use the <list/>, <set/>, <map/>, and <props/> elements to inject values into the properties of list, set, map, and property types.

Sample configuration for injecting collection values:

<BeanID= "Morecomplexobject"class= "Example.complexobject">    <!--results in a setadminemails (java.util.Properties) call -    < Propertyname= "Adminemails">        <Props>            <propKey= "Administrator">[Email protected]</prop>            <propKey= "Support">[Email protected]</prop>            <propKey= "Development">[Email protected]</prop>        </Props>    </ Property>    <!--results in a setsomelist (java.util.List) call -    < Propertyname= "Somelist">        <List>            <value>A list element followed by a reference</value>            <refBean= "myDataSource" />        </List>    </ Property>    <!--results in a setsomemap (JAVA.UTIL.MAP) call -    < Propertyname= "Somemap">        <Map>            <entryKey= "an entry"value= "Just some string" />            <entryKey= "a ref"Value-ref= "myDataSource" />        </Map>    </ Property>    <!--results in a setsomeset (java.util.Set) call -    < Propertyname= "Someset">        <Set>            <value>Just some string</value>            <refBean= "myDataSource" />        </Set>    </ Property></Bean>

Spring (3.2.3)-Beans (5): Injection of collection properties

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.