Spring切入点表达式 expression="execution(*service..*.*(..))"

来源:互联网 发布:javascript代码例子 编辑:程序博客网 时间:2024/06/04 18:57
(* com.evan.crm.service.*.*(..))中几个通配符的含义: 


|第一个 * —— 通配 随便率性返回值类型| 
|第二个 * —— 通配包com.evan.crm.service下的随便率性class| 
|第三个 * —— 通配包com.evan.crm.service下的随便率性class的随便率性办法| 
|第四个 .. —— 通配 办法可以有0个或多个参数| 


 

 

<!-- 配置那些类的方法进行事务管理 --> 
<aop:config> 
<aop:pointcut id="allServiceMethod" expression="execution (* com.cms.sys.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod" /> 
</aop:config> 

还有一个 
execution (* com.cms.art.service.*.*(..))" 

要怎么写?

可以这样写:将execution分开写。 
<aop:config> 
<aop:pointcut id="allServiceMethod" expression="(execution (* com.cms.sys.service.*.*(..)))or (execution (* com.cms.art.service.*.*(..)))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod" /> 
</aop:config>