我的脚被春天弄湿了。我下载了 STS,并且正在遵循 Spring in Action Second Edition 中的基本示例。我在尝试实现基本 AOP 时遇到了困难,我想我只是在我的项目中缺少一些特定的库。
我这么说是因为@Aspect
我的类中无法识别像<aop:config>
我的 xml 中的注释。
这是我的 Maven 依赖项:
- junit-4.7.jar
- spring-test-3.0.2.RELEASE.jar
- spring-context-3.0.2.RELEASE.jar
- spring-aop-3.0.2.RELEASE.jar
- aopalliance-1.0.jar
- spring-beans-3.0.2.RELEASE.jar
- spring-core-3.0.2.RELEASE.jar
- commons-logging-1.1.1.jar
- spring-expression-3.0.2.RELEASE.jar
- spring-asm-3.0.2.RELEASE.jar
- log4j-1.2.14.jar
请让我知道我缺少哪些库以及在哪里可以找到它们。
谢谢!
编辑:
以下:
<bean id="performancePointcut"
class="org.springframework.aop.aspectj.AspectJExpressionPointcut" >
<property name="expression" value="execution(* Performer+.perform(..))" />
</bean>
抛出以下异常:
线程“主”org.springframework.beans.factory.BeanCreationException 中的异常:创建文件 [C:\Users\Prova\Documents\STS\SpringIdol3\src\main\resources\META-INF 中定义的名称为“performancePointcut”的 bean 时出错\spring\spring-idol.xml]: bean 实例化失败;嵌套异常是 java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
完毕!
这个aspectj-annotation-tutorial通过步骤 1、2 和 3 完成了这项工作。
这是一个有趣的周五晚上......