Spring实战Day3
通过xml创建装配bean
1.装配不存在成员变量的bean
<bean id="talent" class="cn.jqzhong.spring.study.day2.literarytalent"></bean>
2.装配存在成员变量的bean
2.1通过构造器注入
2.1.1属性值为引用类型、引用类型列表
<bean id="people" class="cn.jqzhong.spring.study.day2.likemepeople">
<constructor-arg ref="talent"></constructor-arg><constructor-arg>
<list>
<ref bean=""></ref>
<ref bean=""></ref>
</list>
</constructor-arg>
</bean>
2.1.2属性值为字面值、字面值类型列表
<bean id="people" class="cn.jqzhong.spring.study.day2.likemepeople">
<constructor-arg value="xxx"></constructor-arg>
<constructor-arg>
<list>
<value>xxx</value>
<value>xxx</value>
</list>
</constructor-arg>
</bean>
2.2通过属性设置
2.2.1属性值为引用类型、引用类型列表
<bean id="people" class="cn.jqzhong.spring.study.day2.likemepeople">
<property name="talent" ref="talent"></property>
<property>
<list>
<ref bean=""></ref>
<ref bean=""></ref>
</list>
</property>
</bean>
2.2.2属性值为属性值为字面值、字面值类型列表
<bean id="people" class="cn.jqzhong.spring.study.day2.likemepeople">
<property name="talent" value="xxx"></property>
<property name="othertlent">
<list>
<value>xxx</value>
<value>xxx</value>
</list>
</property>
</bean>