问题描述
我在的代码是这样的。<aop:config> <aop:aspect id="TestAspect" ref="aspectBean"> <!--配置com.spring.service包下所有类或接口的所有方法--> <aop:pointcut id="businessService" expression="execution(* com.catsic.business.**.action.*.*(..))" /> <aop:after pointcut-ref="businessService" method="doAfter"/> </aop:aspect> </aop:config> <bean id="aspectBean" class="com.catsic.framework.rzgl.RizhiGlAction" /> 其中 <aop:pointcut id="businessService" expression="execution(* com.catsic.business.**.action.*.*(..))" /> 这一块的代码因为只配置了一个切入点。而实际情况是action的目录参差不齐。我想配置多个切入点怎么办。
解决方案
也可以这样写:将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>可以用or,and,! 连接 也可以|| ,&&,!
解决方案二:
很好,支持下楼上。。