可以用bean 的自动串联,看这个dtd文件<!ATTLIST beans default-autowire (no | byName | byType | constructor |
autodetect) "no">也就是说, 你可以这样定义你的 beans 标记<beans default-autowire="byName">这样,只要你的bean的名字和另外一个bean的属性的名字一样就会自动串联
autodetect) "no">也就是说, 你可以这样定义你的 beans 标记<beans default-autowire="byName">这样,只要你的bean的名字和另外一个bean的属性的名字一样就会自动串联
<bean id="orderService" parent="txTemplate" >
<property name="target">
<bean class="org.thj.bookstore.service.impl.OrderService" autowire="byName"></bean>
</property>
</bean>
<bean id="userAction" class="org.thj.bookstore.action.UserAction">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>
<bean id="bookAction" class="org.thj.bookstore.action.BookAction">
<property name="catalogService">
<ref bean="catalogService"/>
</property>
<property name="bookService">
<ref bean="bookService"/>
</property>
</bean>
<bean id="shoppingAction" autowire="byName" class="org.thj.bookstore.action.ShoppingAction">
</bean>