@AspectJ用于执行包的方法的切入点

Hem*_*lia 2 java aop aspectj spring-aop

我想在特定的包中执行execute方法.

什么可能是一个可能的切入点?

注意:我使用的是@AspectJ样式的Spring AOP.

Sir*_*off 6

看看这里http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html

@(org.xyz..*)匹配任何带有与类型模式匹配的类型的注释的带注释元素(org.xyz..*).换句话说,带有在org.xyz包或子包中声明的注释的带注释的元素.(本例中需要括号).

所以你应该有以下aop配置:

<aop:config>
 <aop:advisor advice-ref="myAdvice" pointcut="execution(* com.mycompany..*(..))" order="1"/> 
</aop:config>
Run Code Online (Sandbox Code Playgroud)

并为此建议匹配bean

<bean id="myadvice" class="com.mycompany.MyIntercetpor"/>
Run Code Online (Sandbox Code Playgroud)

拦截器应该实现org.aopalliance.intercept.MethodInterceptor