Spring - IoC(5): 集合属性的注入
本文内容纲要:Spring - IoC(5): 集合属性的注入
如果 Bean 的属性是个集合,则可以使用 、
注入集合值的配置示例:
<bean id="moreComplexObject" class="example.ComplexObject"> <!-- results in a setAdminEmails(java.util.Properties) call -->
<property name="adminEmails">
<props>
<prop key="administrator">administrator@example.org</prop>
<prop key="support">support@example.org</prop>
<prop key="development">development@example.org</prop>
</props>
</property>
<!-- results in a setSomeList(java.util.List) call -->
<property name="someList">
<list>
<value>a list element followed by a reference</value>
<ref bean="myDataSource" />
</list>
</property>
<!-- results in a setSomeMap(java.util.Map) call -->
<property name="someMap">
<map>
<entry key="an entry" value="just some string" />
<entry key="a ref" value-ref="myDataSource" />
</map>
</property>
<!-- results in a setSomeSet(java.util.Set) call -->
<property name="someSet">
<set>
<value>just some string</value>
<ref bean="myDataSource" />
</set>
</property>
</bean>
本文内容总结:Spring - IoC(5): 集合属性的注入
原文链接:https://www.cnblogs.com/huey/p/4507149.html
以上是 Spring - IoC(5): 集合属性的注入 的全部内容, 来源链接: utcz.com/z/296048.html