AspectJ load time weaving not working for Spring beans

て烟熏妆下的殇ゞ 提交于 2019-12-08 06:09:17

问题


I am facing the same issue as:

AspectJ load time weaving not working on Spring beans

The solution of returning 'Object' is working, but I don't know the reason.

I have gone through:

http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch08s08.html#aop-aj-ltw

but still no clue.


回答1:


As I commented on that other thread.

The load-time weaver, as the name suggest, will only operate on the loading of classes. Now when a class is already loaded it cannot be processed anymore.

When the return type is the concrete class it will result in eagerly loading that class, it will be loaded before the load time weaver is registered and can do it stuff.

When the return type is Object the loading of the class is deferred until the class is actually needed and in general this will be after the load time weaver has been registered so it can do its work.

You can simply verify this behavior by adding -verbose:class as parameters when you run the program (like you would add properties). You then get an extensive list of classes when they get loaded.



来源:https://stackoverflow.com/questions/23445013/aspectj-load-time-weaving-not-working-for-spring-beans

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