问题描述
我用Spring AOP写了一个非常简单的Aspect。它有效,但我在理解真正发生的事情时遇到了一些问题。我不明白为什么我要添加aspectjweaver.jar? Spring-AOP文档明确指出,只要我使用Spring-AOP,我就不需要aspectj编译器或weaver:
i wrote a very simple Aspect with Spring AOP. It works, but i have some problems understanding what is really going on. I don't understand why i have to add the aspectjweaver.jar? The Spring-AOP documentation clearly states that i don't need aspectj compiler or weaver as long as i just use Spring-AOP:
我的配置如下所示:
<aop:aspectj-autoproxy />
@Aspect
@Service
public class RemoteInvocationAspect {
@Before("execution(* at.test.mypackage.*.*(..))")
public void test() {
System.out.println("test");
}
...
我也试过XML配置,没有改变一切。也许我可以放手,但我真的想了解为什么使用aspectj-weaver?如果我不在maven中添加依赖项,我会得到 java.lang.ClassNotFoundException:org.aspectj.weaver.reflect.ReflectionWorld $ ReflectionWorldException
I also tried XML configuration, didn't change anything though. Maybe i could just let it go, but i really would like to understand why aspectj-weaver is used? If i don't add the dependency in maven i get java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
推荐答案
Spring AOP实现我认为重用了aspectj-weaver中的一些类。它仍然使用动态代理 - 不进行字节代码修改。
Spring AOP implementation I think is reusing some classes from the aspectj-weaver. It still uses dynamic proxies - doesn't do byte code modification.
以下可能会澄清。
-Ramnivas
-Ramnivas
这篇关于Spring AOP - 为什么我需要aspectjweaver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!