STS 中缺少 Spring AOP 库
我的脚被春天弄湿了。我下载了 STS,并遵循 Spring in Action Second Edition 中的基本示例。当我尝试实现基本的 AOP 时,我陷入了困境,我想我只是缺少项目中的一些特定库。
我这么说是因为像 @Aspect
这样的注释在我的类中无法识别,就像我的 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>
抛出以下异常:
线程“main”中的异常org.springframework.beans.factory.BeanCreationException:创建文件中定义的名为“performancePointcut”的bean时出错[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
DONE!
这 aspectj-annotation-tutorial 通过步骤完成了这项工作1、2、3。
这是一个有趣的周五晚上......
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.
I say so because annotations like @Aspect
are not recognized in my classes like also <aop:config>
in my xml.
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
Please let me know what libraries I'm missing and where to find them.
Thank you!
EDIT:
The following:
<bean id="performancePointcut"
class="org.springframework.aop.aspectj.AspectJExpressionPointcut" >
<property name="expression" value="execution(* Performer+.perform(..))" />
</bean>
throws the following exception:
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
DONE!
This aspectj-annotation-tutorial did the job with steps 1, 2, and 3.
It's been a fun Friday night....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将这两个依赖项放入 pom.xml 中:
Put these two dependencies in your pom.xml:
您可以添加 Maven 依赖项:
you may add maven dependencies: