You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

spring-retry 2.0.0无法访问注解类求助:升级后注解不可用

Spring Retry 2.0.0 注解无法访问问题解决

问题原因

Spring Retry 2.0.x 版本对模块结构做了拆分,原1.x版本中包含在spring-retry核心jar里的注解类(@EnableRetry、@Retryable、@Recover、@Backoff),在2.0.x中被移到了独立的spring-retry-annotations模块中。仅引入核心依赖会导致无法找到这些注解类。

解决方案

在Maven依赖中添加spring-retry-annotations模块,确保版本与spring-retry保持一致:

<dependency>
    <groupId>org.springframework.retry</groupId>
    <artifactId>spring-retry</artifactId>
    <version>2.0.0</version>
</dependency>
<dependency>
    <groupId>org.springframework.retry</groupId>
    <artifactId>spring-retry-annotations</artifactId>
    <version>2.0.0</version>
</dependency>

额外注意事项

  • 确保项目使用的Spring版本兼容:Spring Retry 2.0.x 需要搭配Spring Framework 5.3+ 或 Spring Boot 2.6+ 使用。
  • 检查代码中的注解导入路径,确认是import org.springframework.retry.annotation.*;,避免导入旧版本的包路径。

内容的提问来源于stack exchange,提问作者Ahmet Dogan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 13:05:21