<?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="stu" class="cn.cslg.spring.collectionType.Stu"> <property name="courseslist"> <list> <ref bean="course"></ref> <ref bean="course2"></ref> </list> </property>
</bean> //创建多个course对象 <bean id="course" class="cn.cslg.spring.collectionType.Course"> <property name="cname" value="spring"></property> </bean> <bean id="course2" class="cn.cslg.spring.collectionType.Course"> <property name="cname" value="spring2"></property> </bean> </beans>