Spring不同类型的注入方式

来源:互联网 发布:王菲演唱会网络直播 编辑:程序博客网 时间:2024/05/18 17:59
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!--==============================================================-->    <!--<bean id="hello" class="com.test.Hello">-->        <!--<property name="msg" value="我是SET注入"></property>-->        <!--<property name="date" ref="date"></property>-->    <!--</bean>-->    <!--<bean id="date" class="java.util.Date"></bean>--><!--===========================================================-->    <bean id="hello" class="com.test.Hello">        <constructor-arg index="0" value="我是构造注入"></constructor-arg>        <constructor-arg index="1" ref="date"></constructor-arg>    </bean>    <bean id="date" class="java.util.Date"></bean>    <bean id="person" class="com.test.Person">        <property name="boys">            <list>                <value>杨过</value>                <value>小龙女</value>                <value>小明</value>            </list>        </property>        <property name="girls">            <set>                <value>小花1</value>                <value>小花2</value>                <value>小花3</value>            </set>        </property>        <property name="guanxi">            <map>                <entry key="杨过1">                    <value>1</value>                </entry>                <entry key="杨过2">                    <value>2</value>                </entry>                <entry key="杨过3">                    <value>3</value>                </entry>            </map>        </property>        <property name="objects">            <list>                <value>date</value>                <ref bean="date"></ref>                <value>hello</value>                <ref bean="hello"></ref>            </list>        </property>        <property name="properties">            <props>                <prop key="1">我是1</prop>                <prop key="2">我是2</prop>            </props>        </property>        <property name="boys2">            <list>                <ref bean="hello"></ref>                <ref bean="hello"></ref>            </list>        </property>    </bean></beans>
0 0
原创粉丝点击