现在有个类:
public abstract class Message {
private Set set;
private List list;
private Map map;
private Properties pro;
//setter方法免写
}
则注入这样写:
<bean id="message"
class="springdemo.Message">
<!-- the injection of the 'Set' collection -->
<property name="set">
<set>
<value>aaa</value>
<value>123</value>
<ref bean="nowTime"/>
</set>
</property>
<!-- the injection of the 'List' collection -->
<property name="list">
<list>
<value>aaa</value>
<value>123</value>
<ref bean="nowTime"/>
<value>Hello world!</value>
</list>
</property>
<!-- the injection of the 'Map' collection -->
<property name="map">
<map>
<entry key="1" value="aaa"></entry>
<entry key="abc" value-ref="nowTime"></entry>
<entry key-ref="nowTime" value-ref="beanA"></entry>
</map>
</property>
<!-- the injection of the 'Property' -->
<property name="pro">
<props>
<prop key="1">ddd</prop>
</props>
</property>
</bean>