我正在尝试使用 AspectJ 和运行时编织。 我创建了一个方面
@Aspect(value = "TraceAspect")
public class TraceAspect {
@Around("execution(* *(..))")
public Object around(ProceedingJoinPoint invocation) throws Throwable{
System.out.println(String.format("Invocing %s", invocation.getSignature().getName()));
try {
Object ret = invocation.proceed();
System.out.println(String.format("Done Invocing %s", invocation.getSignature().getName()));
return ret;
} catch (Throwable throwable) {
throw throwable;
}
}
}
我的aop.xml文件是
<aspectj>
<aspects>
<aspect name="TraceAscpect"></aspect>
</aspects>
<weaver options="-debug -showWeaveInfo"/>
但是当我运行程序时出现异常 -
java.lang.RuntimeException: Cannot register non aspect: TraceAscpect , TraceAscpect
我忘记添加了什么?
最佳答案
看起来您在 XML 定义中拼错了方面的名称,它应该是 TraceAspect
而您输入的是 TraceAscect
。
关于java - AspectJ - 无法注册非方面错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28294405/