Spring之注入集合方式

数组,集合(List,Set,Map),Properties等的注入

数组或者List集合,注入配置文件的方式是一样的

<bean id ="collectionBean" class ="cn.xd.demo2.CoolectionBean">
    <property name="arrs">
        <list>
            <value>小王</value>
            <value>小飞</value>
        </list>
    </property>
</bean>

Set集合,注入的配置文件方式如下

<property name="sets">
    <set>
        <value>你好</value>
        <value>再见</value>
    </set>
</property>

Map集合,配置方式如下

<property name="map">
    <map>
        <entry key="小唐" value="38"/>
        <entry key="小王" value="38"/>
        <entry key="小黄" value="28"/>
    </map>
</property>

Properties属性文件的方式,配置方式如下



123

猜你喜欢

转载自blog.csdn.net/u011301372/article/details/81416029