今天研究 Spring AOP 时候,遇到一个问题,在 XML 配置时一切正常,在改为通过注解配置时候,出现了问题:
Initialization of bean failed;nested exception is java.lang.IllegalArgumentException:error at ::0 can't find referenced pointcut XXX 的错误。
经过后来排查发现,引入了错误的 jar 包。
首先声明,本人的环境是 JDK1.7.
本人引入的错误的 JAR 是 :
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.5.4</version>
</dependency>应该正确引入的 JAR 是:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
</dependencies>
至此问题解决。
本文探讨了在使用Spring AOP进行应用编程时遇到的问题,特别是从XML配置到注解配置过程中出现的Initialization of bean failed错误。文章详细分析了问题原因,并提供了正确的依赖库引入方法,最终成功解决了配置问题。
1082

被折叠的 条评论
为什么被折叠?



