要启用 Spring 重试,可以在 Java 注释中启用重试:在 Configuration 中使用 @EnableRetry 或在 XML 配置文件中指定重试:
<context:annotation-config />
<aop:aspectj-autoproxy />
<bean class="org.springframework.retry.annotation.RetryConfiguration" />
这两个规范都基于仅从版本 1.1.2 开始的…annotation.RetryConfiguration。如何在以前的版本中启用 XML 配置中的重试?由于兼容性问题,我无法使用 1.1.2 版。重试配置如下:
<aop:config>
<aop:pointcut id="retrySave"
expression="execution( * sfweb.service.webServiceOrders.WsOrderCreationServiceImpl.saveLedger(..))" />
<aop:advisor pointcut-ref="retrySave" advice-ref="retryAdvice"
order="-1" />
</aop:config>
<bean id="retryAdvice"
class="org.springframework.retry.interceptor.RetryOperationsInterceptor">
</bean>