为什么服务器抱怨aspectOf 丢失? [英] Why server complaining about aspectOf is missing?

查看:30
本文介绍了为什么服务器抱怨aspectOf 丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试像下面显示的代码一样在 AspectJ 中注入 Spring bean,但是我的服务器(WAS Liberty Profile)一直抱怨缺少方法 aspectOf.我可以知道如何解决这个问题吗?

I am currently trying to inject Spring bean in AspectJ like the code shown below, anyhow I the server (WAS Liberty Profile) keep complaining the method aspectOf is missing. May I know how could I solve this problem?

application-context.xml

<aop:aspectj-autoproxy/>
<import resource="/context-file-A.xml"/>

context-file-A.xml

<bean id="loggingAspect" class="com.huahsin.LoggingAspect" factory-method="aspectOf">

JAVA 代码

@Aspect
public class LoggingAspect {
   ...
}

推荐答案

这是连接方面类时的常见错误.这意味着您的方面类,在这种情况下 LoggingAspect 尚未转换为可以应用的方面.

This is a common error when wiring up aspect classes. It means that your aspect class, in this case LoggingAspect has not been converted into an aspect which can be applied.

将您的类编织到一个方面的两种方法是使用 AJDT Eclipse 插件Maven AspectJ 编译器插件.

2 methods to weave your class into an aspect are using the AJDT Eclipse plugin or the Maven AspectJ compiler plugin.

编织方面有 3 种方法:

There are 3 ways to weave aspects:

  • 编译时编织:通过专用的 aspectj 编译器编译目标源或方面类;
  • 编译后织入:向已编译的类注入方面指令(可应用于 JAR 文件)
  • 加载时编织:在类加载期间向字节码注入方面指令,即加载检测类而不是原始"类;
  • Compile-time weaving: compile either target source or aspect classes via dedicated aspectj compiler;
  • Post-compile weaving: inject aspect instructions to already compiled classes (Can be applied to JAR files)
  • Load-time weaving: inject aspect instructions to the byte code during class loading, i.e. load instrumented class instead of the 'raw' one;

在一个方面类可以应用于一个类之前,它首先需要被编织"成一个方面.

Before an aspect class can be applied to a class it first need to be 'weaved' into an aspect.

编织的方面类将具有这些静态方法 添加.

An weaved aspect class will have these static methods added.

这篇关于为什么服务器抱怨aspectOf 丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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