Using spring AOP aspect to intercept the methods?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 12:10:54

问题


I am using spring AOP to intercept the methods. I have below configuration in my spring config file.

<aop:aspectj-autoproxy />

Aspect class:

@Aspect
public class MyAspect{

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

 //somelogic
}

Above method does not intercept private methods ? what should i do to ask the aspect to intercept both private and public methods?


回答1:


Private methods may not be intercepted, as they may not be invoked through a proxy.

However, you could use native AspectJ weaving, as you can see on the point 8.8.4 of the following page:

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



来源:https://stackoverflow.com/questions/21631328/using-spring-aop-aspect-to-intercept-the-methods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!