系統(tǒng)中有多個(gè)service,但我們的事務(wù)策略大部分都是每個(gè)service都要寫一個(gè)代理配置.多個(gè)service用同樣的事務(wù)策略時(shí),簡化這樣的配置可以用一下方法.
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