sim*_*n_d 7 spring transactions
是否有任何基于配置的替代Spring中的@Transactional注释?
我想让我的java类尽可能免于Spring,即尽可能与任何框架分离.
是的,使用aop:config
和tx:advice
.例如:
<aop:config>
<aop:pointcut id="serviceMethods"
expression="execution(* com.package.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1839 次 |
最近记录: |