聲明式事務,多個execution串連方法:
expression="execution(* pp.business.*.*(..)) or execution(* pp.business.impl.*.*(..))"
spring的協助手冊裡有關於execution的串連方式的一句話:
Pointcut expressions can be combined using '&&', '||' and '!'.
但是我寫上&&就會報錯。很鬱悶。。。
||和or的作用相同:在符合* pp.business.*.*(..)和* pp.business.impl.*.*(..)方法上都加上事務性。
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes ><tx:method name="add*" propagation="REQUIRED"/><tx:method name="delete*" propagation="REQUIRED"/><tx:method name="update*" propagation="REQUIRED"/><tx:method name="insert*" propagation="REQUIRED"/><tx:method name="*" read-only="true"/></tx:attributes></tx:advice><aop:config proxy-target-class="true"> <aop:pointcut id="allManagerMethod" expression="execution(* pp.business.*.*(..)) or execution(* pp.business.impl.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/></aop:config>