STS中缺少Spring AOP库 [英] Missing Spring AOP libraries in STS
问题描述
我正在用Spring弄湿我的脚.我下载了STS,并且正在遵循Spring in Action Second Edition中的基本示例.在尝试实现基本AOP时遇到了麻烦,我想我只是在项目中缺少了一些特定的库.
I'm getting my feet wet with Spring. I downloaded STS and I'm following basic examples from Spring in Action Second Edition. I'm stuck when trying to implement basic AOP and I guess I'm just missing some specific libraries in my project.
之所以这么说是因为像我的xml中的<aop:config>
一样,在类中无法识别像@Aspect
这样的注释.
I say so because annotations like @Aspect
are not recognized in my classes like also <aop:config>
in my xml.
这是我的Maven依赖项:
This are my Maven Dependencies:
- 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
- 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
请让我知道我缺少哪些库以及在哪里可以找到它们.
Please let me know what libraries I'm missing and where to find them.
谢谢!
以下内容:
<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 \ spring \ spring-idol.xml]:实例化Bean失败;嵌套的异常是java.lang.NoClassDefFoundError:org/aspectj/weaver/reflect/ReflectionWorld $ ReflectionWorldException
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'performancePointcut' defined in file [C:\Users\Prova\Documents\STS\SpringIdol3\src\main\resources\META-INF\spring\spring-idol.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
完成!
此 aspectj-annotation-tutorial 做到了具有步骤1、2和3的作业.
This aspectj-annotation-tutorial did the job with steps 1, 2, and 3.
星期五晚上真有趣....
It's been a fun Friday night....
推荐答案
将这两个依赖项放入pom.xml中:
Put these two dependencies in your pom.xml:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.11</version>
</dependency>
这篇关于STS中缺少Spring AOP库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!