<bean id="messageProvider"
class="com.apress.prospring3.ch4.xml.HelloWorldMessageProvider"/>
</beans>
Listing 4-22. Annotation Configuration (app-context-annotation.xml)
<?xml version="1.0" encoding="UTF-8"?>
<context:annotation-config/>
<context:component-scan
base-package="com.apress.prospring3.ch4.annotation"/>
</beans>
Using Setter Injection
To configure Setter Injection using XML configuration, you need to specify <property> tags under the
<bean> tag for each <property> into which you want to inject a dependency. For example, to assign the
message provider bean to the messageProvider property of the messageRenderer bean, you simply change
the <bean> tag for the messageRenderer bean, as shown in Listing 4-23.
Listing 4-23. Setter Injection (XML)
<bean id="messageRenderer" class="com.apress.prospring3.ch4.xml.StandardOutMessageRenderer">
<property name="messageProvider">
<ref bean="messageProvider"/>
</property>
</bean>
Search WWH :