java – 如何调试Spring AOP

前端之家收集整理的这篇文章主要介绍了java – 如何调试Spring AOP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个 Spring AOP的问题,它不涉及所有方法(在我看来)(参见这个问题更多关于根问题: Spring AOP ignores some methods of Hessian Service).

如何调试,什么方法和实例结合什么方面?有没有像spring aop那样的详细标志,这给了这些信息?

解决方法

在Spring AOP类中似乎没有太多的日志记录代码,但…

如果Spring AOP决定使用Cglib来创建代理,那么有一行可以帮助你:

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

当使用JDK代理时,类似的一个似乎很方便:

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

只需尝试打开这两个类的DEBUG级别日志记录,看看是什么输出.

原文链接:https://www.f2er.com/java/126558.html

猜你在找的Java相关文章