如何调试 Spring AOP [英] How to debug Spring AOP

查看:38
本文介绍了如何调试 Spring AOP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Spring AOP 有一个问题,它没有将一个方面与其应该的所有方法联系起来(在我看来)(有关根本问题的更多信息,请参阅此问题:Spring AOP忽略了Hessian Service的一些方法).

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).

如何调试,哪些方法和实例与哪些方面结合?是否有类似 spring aop 的详细标志,提供该信息?

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?

推荐答案

Spring AOP 类中似乎没有太多日志记录代码,但是...

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

如果 Spring AOP 决定使用 Cglib 创建代理,有一行可能对您有所帮助:

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());
    }

当使用 JDK 代理时,类似的方法似乎会派上用场:

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());
    }

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

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

这篇关于如何调试 Spring AOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆