spring集合类型注入

spring集合类型注入

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="chinese" class="Bean.collections.Chinese">
    <!--List 注入例子-->
    <property name="schools">    
      <list>
         <value>小学</value>
         <value>中学</value>
         <value>大学</value>
      </list>
    </property>
    <!--Properties 注入例子-->
    <property name="health">
       <props>
         <prop key="血压">正常</prop>
         <prop key="身高">178</prop>
       </props>
    </property>
    <!--Map 注入例子-->
    <property name="scores">
      <map>
        <entry key="数学">
           <value>88</value>
        </entry>
        <entry key="语文">
           <value>99</value>
        </entry>
      </map>
    </property>
 
<!--Map 例子-->
 <bean id="accountConfig" class="java.util.HashMap">
  <constructor-arg>
   <map>
    <entry key="accountResourceSQL">
     <value>SELECT * FROM ABC</value>
    </entry>
   </map>
  </constructor-arg>
 </bean>
 
    <!-Set 注入例子-->
    <property name="axes">
      <set>
        <value>字符串斧子</value>
        <!-- 用嵌套bean定义属性 -->
        <bean class="Bean.collections.WoodAxe"/>
        <!-- 引用bean作为属性 -->
        <ref local="steelaxe"/>
      </set>
    </property>
  <!--array 注入例子-->
  <property name="array">   
   <list>   
    <value>array1</value>   
    <value>array2</value>   
   </list>   
  </property> 
  </bean>
  <bean id="steelaxe" class="Bean.collections.SteelAxe"></bean>
</beans>
原文地址:https://www.cnblogs.com/olmlo/p/5502625.html