使用Spring AOP方面拦截方法?

use*_*829 2 java spring spring-aop

我正在使用spring AOP来拦截这些方法.我的spring配置文件中有以下配置.

<aop:aspectj-autoproxy />
Run Code Online (Sandbox Code Playgroud)

Aspect类:

@Aspect
public class MyAspect{

 @Around("execution(public * *(..))")
public Object doAction(ProceedingJoinPoint call) throws Throwable {

 //somelogic
}
Run Code Online (Sandbox Code Playgroud)

以上方法不拦截私有方法?我该怎么做才能要求方面拦截私人公共方法?

And*_*res 5

私有方法可能不会被截获,因为它们可能无法通过代理调用.

但是,您可以使用本机AspectJ编织,如以下页面的第8.8.4点所示:

http://docs.spring.io/spring/docs/4.0.0.RELEASE/spring-framework-reference/html/aop.html#aop-pointcuts-designators