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

Spring Boot集成OpenTelemetry Starter启动报错求助

问题分析与解决方案

问题根源

你遇到的ClassNotFoundException是因为OpenTelemetry核心SDK与Instrumentation Starter的版本不兼容:

  • 同时引入了opentelemetry-bom:1.40.0-alpha(核心SDK的alpha版本)和opentelemetry-instrumentation-bom-alpha:2.6.0(Instrumentation的alpha版本),两者版本不匹配导致依赖类结构不一致;
  • 手动指定的opentelemetry-sdk-extension-autoconfigure等依赖版本(1.40.0)与Instrumentation Starter(2.6.0)所需版本不对应,缺失了AutoConfigureListener类。

解决步骤

1. 统一依赖版本管理

移除单独的核心SDK BOM和手动指定的autoconfigure依赖,使用Instrumentation BOM统一管理所有OpenTelemetry相关依赖版本,它会自动关联兼容的核心SDK版本:

修改后的build.gradle依赖部分:

// 用Instrumentation BOM管理所有相关依赖版本
implementation platform('io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.6.0')
// 仅引入starter,其他依赖由BOM自动引入
implementation 'io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter'

2. 清理并重新构建

执行./gradlew clean build清理旧依赖缓存并重新构建项目,之后重启应用验证错误是否消失。

补充说明

你找到的相关问题本质也是版本不匹配导致的依赖冲突,通过统一使用Instrumentation BOM即可彻底解决这类版本兼容问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 15:52:37