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

查看:232
本文介绍了为什么服务器抱怨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.

将方法编织成方面的2种方法是使用 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.

编织方面有三种方法:


  • 编译 - 时间编织:通过专用的aspectj编译器编译目标源或方面类;

  • 编译后编织:向已编译的类注入方面指令(可以应用于JAR文件)

  • 加载时编织:在类加载期间将方面指令注入字节代码,即加载已检测的类而不是'raw 'one;

  • 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天全站免登陆