如何调试Spring AOP [英] How to debug Spring AOP
问题描述
我遇到Spring AOP的问题,它没有将方面与它应该的所有方法联系起来(在我看来)(有关根问题的更多信息,请参阅此问题: Spring AOP忽略了一些Hessian服务方法。
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屋!