Spring AOP生成的代理类的位置 [英] Location of the proxy class generated by Spring AOP

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

问题描述

仅出于学习和理解代理的目的,我想看看Spring AOP生成的代理类.它在Eclipse生成的classes文件夹中不存在.

Just for the sake of learning and understanding proxies, I wanted to see the proxy class generated by Spring AOP. It was not present in the classes folder generated by Eclipse.

有人可以告诉我它的位置吗?

Can somebody tell me its location?

推荐答案

如果您使用的是基于接口的代理(默认),则Spring使用

If you are using interface-based proxies (default), Spring uses Proxy class to create proxy dynamically and in-memory. There is no .class file associated with that class.

在使用基于类的代理时(通过)Spring创建您的类的具体子类.在调试器中,您会注意到它们的名称类似于YourRealService$$EnhancerByCGLIB$$...,但同样,这些类仅在内存中生成,而不存储在磁盘上.

When using class-based proxies (via cglib) Spring creates concrete subclasses of your classes. In the debugger you'll notice they are named something like YourRealService$$EnhancerByCGLIB$$... But again, these classes are only generated in-memory and not stored on disk.

如果您真的想在幕后看到AOP,则必须使用和编译时编织.太多的工作.因此,最重要的是:相信他们的工作.如果没有,请检查堆栈跟踪.

If you really want to see AOP under the hood, you will have to use aspectj and compile-time weaving. Way too much work. So the bottom line is: just trust they work. And if they don't: examine stack traces.

这篇关于Spring AOP生成的代理类的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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