【SpringInAction】 基本Bean装配 Demo

[quote]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<bean id="sonnet29" class="com.lh.springtest02.section2.Sonnet29" />
<bean id="saxophone" class="com.lh.springtest02.section2.Saxophone" />
<bean id="harmonica" class="com.lh.springtest02.section2.Harmonica" />
<bean id="guitar" class="com.lh.springtest02.section2.Guitar" />
<bean id="hank" class="com.lh.springtest02.section2.OneManBand">
<property name="instruments">
<!--
<list>
<ref bean="saxophone"/>
<ref bean="guitar"/>
<ref bean="harmonica"/>
</list> -->
<set>
<ref bean="saxophone"/>
<ref bean="harmonica"/>
<ref bean="guitar"/>
<ref bean="guitar"/>
</set>
</property>
</bean>
<bean id="hank2" class="com.lh.springtest02.section2.OneManBand2">
<property name="instruments">
<map>
<entry key="guitar" value-ref="guitar" />
<entry key="harmonica" value-ref="harmonica" />
<entry key="saxophone" value-ref="saxophone" />
</map>
</property>
</bean>

<bean id="hankprop" class="com.lh.springtest02.section2.OneManBandProp">
<property name="instruments">
<props>
<prop key="GUITAR">GUITAR GUITAR GUITAR</prop>
<prop key="HARMONICA">HARMONICA HARMONICA HARMONICA</prop>
<prop key="SAXOPHONE">SAXOPHONE SAXOPHONE SAXOPHONE</prop>
</props>
</property>
</bean>

<bean id="duke" class="com.lh.springtest02.section2.Juggler">
<constructor-arg value="15"></constructor-arg>
</bean>
<bean id="duke2" class="com.lh.springtest02.section2.PoeticJuggler">
<constructor-arg value="16" />
<constructor-arg ref="sonnet29"/>
</bean>

<bean id="kenny" class="com.lh.springtest02.section2.Instrumentalist">
<!--
<property name="song" value="Jinggle Bells" />
<property name="age" value="28"/>
-->
<property name="song"><null/></property>
<property name="age" value="28"/>
<property name="instrument" ref="saxophone" />
<!-- <property name="instrument">
<bean class="com.lh.springtest02.section2.Saxophone" />
</property> -->
</bean>
</beans>
[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值