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

Maven 3.9.5配置aether.connector.http.headers添加自定义头失败求助

Maven 3.9.5命令行设置自定义HTTP头不生效的解决方法

问题重现

使用Maven 3.9.5,尝试通过命令行参数-Daether.connector.http.headers=key:value为依赖下载的HTTP请求添加自定义头,但代理监控中未发现该头,仅常规头存在,且希望无需修改settings.xml。

解决方案

问题出在参数格式错误,aether.connector.http.headers是Map类型配置项,不能直接用key:value格式赋值,需要采用点语法指定每个键值对:

mvn install -Daether.connector.http.headers.key=value

如果需要添加多个自定义头,只需追加多个参数:

mvn install -Daether.connector.http.headers.header1=value1 -Daether.connector.http.headers.header2=value2

原因说明

Maven Resolver(原Aether)的aether.connector.http.headers配置本质是一个键值对映射,命令行传递Map类型参数时,必须通过配置项.键=值的格式来让Maven正确解析为对应的HTTP请求头。直接传入key:value会被当作单个字符串值,无法被解析为有效的请求头键值对。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 13:42:06