什么是bean的装配
指的是用户将自己开发的Bean装配到Spring Ioc容器中
Bean的装配方式1----在XML文件中显式装配
- 简易值的装配
指的是一般数据类型的装配;比如说Integer、String等;可以参考上一篇博客 - 集合装配
Set、Map、List、Array、Properties
<bean id="favorite1" class="com.bean.Favorite">
<property name="favoriteName" value="踢球"/>
</bean>
<bean id="user1" class="com.bean.User">
<property name="id" value="1"/>
<property name="name" value="刘飞红"/>
<property name="employee" value="总经理"/>
<property name="favorite" ref="favorite1"/>
</bean>
<!--
<bean id="favorite2" class="com.bean.Favorite">
<constructor-arg index="0" value="篮球"/>
</bean>
<bean id="user2" class="com.bean.User">
<constructor-arg index="0" value="2"/>
<constructor-arg index="1" value="刘颖"/>
<constructor-arg index="2" value="部门经理"/>
<constructor-arg index="3" ref="favorite2"/>
</bean>
-->
<bean id="special" class="com.bean.SpecialLoad" >
<property name="set">
<set>
<value>set-value1</value>
<value>set-value3</value>
</set>
</property>
<property name="map">
<map>
<entry key="map-key1" value="map-value1"/>
<entry key="map-key2" value="map-value2"/>
</map>
</property>
<property name="list">
<list>
<value>list-value-1</value>
<value>list-value-2</value>
</list>
</property>
<property name="array">
<array>
<value>array-value1</value>
<value>array-value2</value>
</array>
</property>
<property name="properties">
<props>
<prop key="prop1">prop-value-1</prop>