How to debug Spring AOP

依然范特西╮ 提交于 2019-12-31 22:23:06

问题


I have a problem with Spring AOP which doesn't ties an aspect to all the methods it should (in my opinion) (see this question for more about the root problem: Spring AOP ignores some methods of Hessian Service).

How can I debug, what methods and instances get combined with what aspect? Is there something like a verbose flag for spring aop, which gives that information?


回答1:


There seems not to be too much logging code in the Spring AOP classes, but...

In case Spring AOP decides to use Cglib to create proxy, there's one line which might help you:

    // in org.springframework.aop.framework.Cglib2AopProxy.getProxy(ClassLoader)
    if (logger.isDebugEnabled()) {
        logger.debug("Creating CGLIB2 proxy: target source is " + this.advised.getTargetSource());
    }

A similar one seems to come in handy when JDK proxies are used:

    // in org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(ClassLoader)
    if (logger.isDebugEnabled()) {
        logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
    }

Just try to turn on DEBUG-level logging for these two classes and see what's the output.



来源:https://stackoverflow.com/questions/5141853/how-to-debug-spring-aop

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