标签:spring ref try line 亦或 util set ber nts
虽然不多,但是有时候在实现的时候,我们还是希望某些参数或者属性通过集合()的方式注入进来,比如配置表参数列表,addresslist,亦或是三方库等等。因为这种改动不是很多,经常一时想不起来,今天做个类通用业务AOP的时候用到,顺便记录下:
<
bean
id="CustomerBean" class="com.mkyong.common.Customer">
<!-- java.util.List -->
<
property
name="lists">
<
list
>
<
ref
bean="PersonBean" />
<
bean
class="com.mkyong.common.Person">
<
property
name="name" value="mkyongList" />
<
property
name="address" value="address" />
<
property
name="age" value="28" />
</
bean
>
</
list
>
</
property
>
<!-- java.util.Set -->
<
property
name="sets">
<
set
>
<
ref
bean="PersonBean" />
<
bean
class="com.mkyong.common.Person">
<
property
name="name" value="mkyongSet" />
<
property
name="address" value="address" />
<
property
name="age" value="28" />
</
bean
>
</
set
>
</
property
>
<!-- java.util.Map -->
<
property
name="maps">
<
map
>
<
entry
key="Key 1" value="1" />
<
entry
key="Key 2" value-ref="PersonBean" />
<
entry
key="Key 3">
<
bean
class="com.mkyong.common.Person">
<
property
name="name" value="mkyongMap" />
<
property
name="address" value="address" />
<
property
name="age" value="28" />
</
bean
>
</
entry
>
</
map
>
</
property
>
<!-- java.util.Properties -->
<
property
name="pros">
<
props
>
<
prop
key="admin">admin@nospam.com</
prop
>
<
prop
key="support">support@nospam.com</
prop
>
</
props
>
</
property
>
</
bean
>
<
bean
id="PersonBean" class="com.mkyong.common.Person">
<
property
name="name" value="mkyong1" />
<
property
name="address" value="address 1" />
<
property
name="age" value="28" />
</
bean
>
spring List,Set,Map,Properties,array的配置文件注入方式
标签:spring ref try line 亦或 util set ber nts
原文地址:http://www.cnblogs.com/zhjh256/p/6548809.html