Spring重试1.2.4和Spring 4.3.22抱怨缺少Aspect依赖项

时间:2019-02-22 17:52:03

标签: aop aspectj aspect spring-retry

我正在尝试向自己的方法之一添加@Retryable注释,由于我无法使用@Configuration类,因此我在春季<beans>中使用xml来完成此操作,如下所示:

    <context:annotation-config />
    <aop:aspectj-autoproxy />
    <bean id="retryAdvice"
          class="org.springframework.retry.interceptor.RetryOperationsInterceptor"/>

我的应用程序抱怨Pointcut不可用

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Pointcut
    at org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.<clinit>(AbstractAspectJAdvisorFactory.java:62)
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Pointcut
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

但根据maven,它在我的类路径中,作为aspectjweaver 1.8.9的一部分

# mvn dependency:tree
[INFO] +- org.springframework.retry:spring-retry:jar:1.2.4.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.3.22.RELEASE:compile
[INFO] |  \- org.springframework:spring-beans:jar:4.3.22.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.3.22.RELEASE:compile
[INFO] +- org.springframework:spring-aspects:jar:4.3.22.RELEASE:compile
[INFO] |  \- org.aspectj:aspectjweaver:jar:1.8.9:compile

如您所见,我使用的是Spring 4.3.22,但似乎添加spring-aspects作为依赖项不足以使spring-retry正常工作,即使它拉了aspectjweaver。我想念什么吗?

0 个答案:

没有答案