Spring:属性及构造函数注入
使用setter注入:
<bean id="activeMqMessaging" class="com.websystique.spring.domain.impl.ActiveMQMessaging" />
<bean id="communication" class="com.websystique.spring.Communication">
<property name="messaging">
<ref bean="activeMqMessaging" />
</property>
</bean>
使用构造方法注入:
<bean id="rsaEncryption" class="com.websystique.spring.domain.impl.RSAEncryption" />
<bean id="communication" class="com.websystique.spring.Communication">
<constructor-arg>
<ref bean="rsaEncryption" />
</constructor-arg>
</bean>
同时使用setter及构造方法注入:
<bean id="activeMqMessaging" class="com.websystique.spring.domain.impl.ActiveMQMessaging" />
<bean id="rsaEncryption" class="com.websystique.spring.domain.impl.RSAEncryption" />
<bean id="communication" class="com.websystique.spring.Communication">
<constructor-arg>
<ref bean="rsaEncryption" />
</constructor-arg>
<property name="messaging">
<ref bean="activeMqMessaging" />
</property>
</bean>