系統中有多個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