spring事务配置多个切点,即多个execution

来源:互联网 发布:人生到处知何似 编辑:程序博客网 时间:2024/06/14 04:17
<aop:config><!-- 配置多个切点,&& || ! --><aop:pointcut id="pc" expression="execution(public * com.wtas.*.service.*.*(..)) || execution(public * com.wtas.*.*.service.*.*(..)) || execution(public * com.wtas.*.*.*.service.*.*(..))" /><aop:advisor pointcut-ref="pc" advice-ref="userTxAdvice" /></aop:config>

其中,&&,||,可以写成and,or,但是需要注意大小写,我在讲||换成大写的OR的时候,不能进行事务控制,不知道是不是区别别大小写的。

还有一种做法,就是写多个aop:advisor:

<aop:advisor pointcut="execution(public * com.wtas.*.service.*.*(..))" advice-ref="userTxAdvice" />
<aop:advisor pointcut="execution(public * com.wtas.*.*.service.*.*(..))" advice-ref="userTxAdvice" />