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

Spring Boot 1.5集成Uber Jaeger分布式追踪报错求助

Spring Boot 1.5 集成Jaeger 解决ReporterAppender Bean缺失问题

问题根源

opentracing-spring-jaeger-cloud-starter 1.0.0 与Spring Boot 1.5的自动配置机制存在兼容性问题,导致starter内部依赖的ReporterAppender Bean无法被自动创建;另外,cloud版starter可能依赖了更高版本的Spring Cloud组件,进一步加剧了版本不匹配问题。

解决方案

1. 替换为非Cloud版starter并调整版本

Spring Boot 1.5更适配基础版的opentracing-spring-jaeger-starter,建议移除opentracing-spring-jaeger-cloud-starter,改用兼容的版本:

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-spring-jaeger-starter</artifactId>
    <version>0.31.0</version>
</dependency>

这个版本专门针对Spring Boot 1.x做了适配,能自动初始化所需的Bean。

2. 手动创建ReporterAppender Bean

如果坚持使用原cloud starter,可在项目的配置类中手动定义该Bean,绕过自动配置的缺失:

import io.opentracing.contrib.java.spring.jaeger.starter.ReporterAppender;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JaegerCustomConfig {

    @Bean
    public ReporterAppender reporterAppender() {
        return new ReporterAppender();
    }
}

3. 核对配置文件

确保Jaeger的配置项没有冲突,示例application.properties配置:

# Jaeger服务名称
opentracing.jaeger.service-name=your-service-id
# 采样器配置(全采样)
opentracing.jaeger.sampler.type=const
opentracing.jaeger.sampler.param=1
# 上报地址(默认localhost:6831)
opentracing.jaeger.reporter.endpoint=http://localhost:14268/api/traces

4. 清理依赖冲突

执行mvn dependency:tree(Maven)或./gradlew dependencies(Gradle)检查依赖树,排除与Spring Boot 1.5冲突的高版本组件,比如Spring Cloud相关依赖。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 16:05:04