系统中有多个service,但我们的事务策略大部分都是每个service都要写一个代理配置.多个service用同样的事务策略时,简化这样的配置可以用一下方法.
xml代码: |
<!-- Transactional proxy for the services --> <bean id="baseTxProxy" lazy-init="true" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref bean="transactionManager"/></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean>
<bean id="itemService" parent="baseTxProxy"> <property name="target"> <bean class="ItemServiceImpl" autowire="byName"/> </property> </bean>
|
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=245954