<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!--配置bean-->
<bean id="helloTest" class="com.spring.HelloTest">
<property name="name">
<value><![CDATA[Shanghai^]]></value>
</property>
</bean>
<bean id="car" class="com.spring.Car">
<constructor-arg index="0" value="Audi"/>
<constructor-arg index="1" value="Shanghai"/>
<constructor-arg type="double" value="300000"/>
</bean>
<bean id="car2" class="com.spring.Car">
<constructor-arg type="java.lang.String" value="BMW"/>
<constructor-arg type="java.lang.String">
<value><![CDATA[Shanghai^]]></value>
</constructor-arg>
<constructor-arg type="int"><value>250</value></constructor-arg>
</bean>
<bean id="person" class="com.spring.Person">
<property name="name" value="Tom"/>
<property name="age" value="20"/>
<!--<property name="car" ref="car2"/>-->
<property name="car"><null/></property>
</bean>
<bean id="person2" class="com.spring.Person">
<property name="name" value="Tom"/>
<property name="age" value="20"/>
<!--<property name="car">-->
<!--<ref bean="car2"></ref>-->
<!--</property>-->
<!--<property name="car">-->
<!--<bean class="com.spring.Car">-->
<!--<!–<property name="brand" value="Tom"/>–>-->
<!--<constructor-arg value="Ford"></constructor-arg>-->
<!--<constructor-arg value="changan"></constructor-arg>-->
<!--<constructor-arg value="20000" type="double"></constructor-arg>-->
<!--</bean>-->
<!--</property>-->
</bean>
<bean id="person3" class="com.spring.Person">
<constructor-arg value="Tom"></constructor-arg>
<constructor-arg value="24"></constructor-arg>
<constructor-arg><null/></constructor-arg>
</bean>
<!--<bean id="person4" class="com.spring.Person">-->
<!--<constructor-arg value="Tom"></constructor-arg>-->
<!--<constructor-arg value="24"></constructor-arg>-->
<!--<constructor-arg>-->
<!--<bean class="com.spring.Car">-->
<!--<!–<property name="brand" value="Tom"/>–>-->
<!--<constructor-arg value="Ford"></constructor-arg>-->
<!--<constructor-arg value="changan"></constructor-arg>-->
<!--<constructor-arg value="20000" type="double"></constructor-arg>-->
<!--</bean>-->
<!--</constructor-arg>-->
<!--<constructor-arg ref="car"></constructor-arg>
<property name="car.brand" value="brand"></property>-->
<!--</bean>-->
<bean id="person5" class="com.spring.Person">
<property name="name" value="Tom"/>
<property name="age" value="20"/>
<property name="car">
<list>
<ref bean="car"></ref>
<ref bean="car2"></ref>
<bean class="com.spring.Car">
<!--<property name="brand" value="Tom"/>-->
<constructor-arg value="Ford"></constructor-arg>
<constructor-arg value="changan"></constructor-arg>
<constructor-arg value="20000" type="double"></constructor-arg>
</bean>
</list>
</property>
</bean>
<bean id="newPerson" class="com.spring.NewPerson">
<property name="name" value="lsd"></property>
<property name="age" value="24"></property>
<property name="cars">
<map>
<entry key="AA" value-ref="car"></entry>
<entry key="BB" value-ref="car2"></entry>
<entry key="CC">
<bean class="com.spring.Car">
<!--<property name="brand" value="Tom"/>-->
<constructor-arg value="Ford"></constructor-arg>
<constructor-arg value="changan"></constructor-arg>
<constructor-arg value="20000" type="double"></constructor-arg>
</bean>
</entry>
</map>
</property>
</bean>
<!--配置prop属性值-->
<bean id="dataSouce" class="com.spring.DataSouce">
<property name="properties">
<props>
<prop key="user">lsd</prop>
</props>
</property>
</bean>
<!--配置独立的集合bean,多个bean可以单独使用-->
<util:list id="cars">
<ref bean="car"></ref>
<ref bean="car2"></ref>
</util:list>
<bean id="person7" class="com.spring.Person">
<property name="name" value="Tom"/>
<property name="age" value="20"/>
<property name="car" ref="cars"/>
</bean>
<!--通过p命名空间为bean的属性赋值-->
<bean id="person8" class="com.spring.Person" p:age="30" ></bean>
</beans>
01-31
168
10-14