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

Spring Cloud Sleuth 3.1.6与2022.0.4不兼容问题解决方案咨询

解决Spring Cloud 2022.0.4与Spring Cloud Sleuth 3.1.6版本不兼容问题

问题原因

Spring Cloud 2022.0.x(Kilburn版本)已不再兼容Spring Cloud Sleuth,官方已将链路追踪功能迁移至Micrometer Tracing,Sleuth 3.1.x是该组件的最后一个维护版本,仅适配Spring Cloud 2021.0.x(Jubilee)及更早版本。

解决方案

方案1:临时禁用兼容性检查(仅应急使用)

如果需要快速启动项目,可通过配置关闭Spring Cloud的兼容性校验:
在application.properties或application.yml中添加:

spring.cloud.compatibility-verifier.enabled=false

⚠️ 注意:此方法仅能跳过校验,无法解决潜在的兼容性问题,长期使用可能引发未知BUG,不推荐用于生产环境。

方案2:迁移至Micrometer Tracing(推荐)

这是官方推荐的长期解决方案,步骤如下:

  1. 移除Sleuth相关依赖
    修改pom.xml,删除原有的Sleuth依赖:
<!-- 移除以下依赖 -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
    <version>3.1.6</version>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-sleuth-zipkin</artifactId>
    <version>3.1.6</version>
</dependency>
  1. 添加Micrometer Tracing及Zipkin依赖
    在pom.xml中加入替代依赖(无需指定版本,Spring Cloud 2022.0.x会自动管理兼容版本):
<dependencies>
    <!-- Micrometer Tracing核心依赖 -->
    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-tracing-bridge-brave</artifactId>
    </dependency>
    <!-- Zipkin上报依赖 -->
    <dependency>
        <groupId>io.zipkin.reporter2</groupId>
        <artifactId>zipkin-reporter-brave</artifactId>
    </dependency>
</dependencies>
  1. 配置调整(如需)
    原有Sleuth的大部分配置可直接沿用,例如Zipkin地址配置:
spring.zipkin.base-url=http://your-zipkin-server:9411

若有自定义链路追踪逻辑,只需将Sleuth的Tracer替换为Micrometer Tracing的Tracer(来自io.micrometer.tracing.Tracer包),API使用方式基本一致。

内容的提问来源于stack exchange,提问作者Saransh Tyagi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 01:44:52