AspectJ加载时间编织不适用于Spring Bean [英] AspectJ load time weaving not working for Spring beans

查看:98
本文介绍了AspectJ加载时间编织不适用于Spring Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临与以下问题相同的问题:

I am facing the same issue as:

AspectJ加载时间编织在Spring bean上不起作用

返回对象"的解决方案有效,但我不知道原因.

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

我经历过:

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

但仍然没有任何线索.

推荐答案

当我在其他线程上发表评论时.

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.

当返回类型为Object时,该类的加载将推迟到实际需要该类时进行,通常,这是在注册了加载时间编织者之后才能进行的.

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.

您可以通过在运行程序时添加-verbose:class作为参数来简单地验证此行为(就像添加属性一样).然后,在加载类时,您将获得大量的类列表.

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.

这篇关于AspectJ加载时间编织不适用于Spring Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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