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

Maven未正确解析netty-codec-http2传递依赖问题

问题分析:Netty Codec HTTP2版本被降级的原因

核心原因

你看到的io.netty:netty-codec-http2实际解析为4.1.97.Final而非预期的4.1.101.Final,本质是Maven依赖解析规则和依赖传递链中的版本声明优先级导致的:

  1. Azure Core HTTP Netty的直接版本锁定
    com.azure:azure-core-http-netty:1.13.11的POM文件中,直接将io.netty:netty-codec-http2的版本声明为4.1.97.Final。这个传递依赖中的直接版本声明,优先级高于未在**当前项目依赖管理(dependencyManagement)**中明确覆盖的继承管理版本。

  2. 依赖管理的优先级规则
    依赖树中显示的(version managed from 4.1.101.Final),说明你的项目继承链中(比如间接引入的第三方父POM)存在该依赖的4.1.101.Final版本声明,但由于你的父POM并未在自身的dependencyManagement中明确管控io.netty:netty-codec-http2的版本,Maven会优先采用传递依赖链中距离最近的直接声明版本(即azure-core-http-netty指定的4.1.97.Final)。

验证步骤

你可以通过以下方式确认上述结论:

  • 执行命令查看azure-core-http-netty的依赖详情:
    mvn dependency:tree -Dverbose -Dartifact=com.azure:azure-core-http-netty:1.13.11
    
  • 直接查看本地Maven仓库中该依赖的POM文件(路径示例:~/.m2/repository/com/azure/azure-core-http-netty/1.13.11/azure-core-http-netty-1.13.11.pom),搜索netty-codec-http2即可看到它的版本声明。

版本修正方案(若需升级到4.1.101.Final)

在父POM的dependencyManagement中明确添加Netty依赖的版本管控,强制Maven使用指定版本覆盖传递依赖:

<dependencyManagement>
  <dependencies>
    <!-- 保留已有的Azure依赖管理项 -->
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http2</artifactId>
      <version>4.1.101.Final</version>
    </dependency>
  </dependencies>
</dependencyManagement>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 19:17:02