系统中有多个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> |
系统存在多个service,多数事务策略需为每个service写代理配置。当多个service采用相同事务策略时,可通过特定方法简化此类配置。

570

被折叠的 条评论
为什么被折叠?



