Maven 依赖项失败并出现 501 错误 [英] Maven dependencies are failing with a 501 error
问题描述
最近在 Jenkins 中运行的 Maven 构建作业失败,出现以下异常,表示它们无法从 Maven Central 中提取依赖项,并且应该使用 HTTPS.我不确定如何将请求从 HTTP 更改为 HTTPS.有人可以指导我解决这个问题吗?
Recently Maven build jobs running in Jenkins are failing with the below exception saying that they couldn't pull dependencies from Maven Central and should use HTTPS. I'm not sure how to change the requests from HTTP to HTTPS. Could someone guide me on this matter?
[错误] 无法解析的构建扩展:
插件 org.apache.maven.wagon:wagon-ssh:2.1
或其依赖项之一无法解析:
未能为 org.apache.maven.wagon:wagon-ssh:jar:2.1 ()
收集依赖项:
无法读取 org.apache.maven.wagon:wagon-ssh:jar:2.1
:
的工件描述符无法从/向中央传输工件 org.apache.maven.wagon:wagon-ssh:pom:2.1
(http://repo.maven.apache.org/maven2):
传输文件失败:http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom.
返回码为:501,ReasonPhrase:HTTPS 必填.->[帮助2]
[ERROR] Unresolveable build extension:
Pluginorg.apache.maven.wagon:wagon-ssh:2.1
or one of its dependencies could not be resolved:
Failed to collect dependencies fororg.apache.maven.wagon:wagon-ssh:jar:2.1 ()
:
Failed to read artifact descriptor fororg.apache.maven.wagon:wagon-ssh:jar:2.1
:
Could not transfer artifactorg.apache.maven.wagon:wagon-ssh:pom:2.1
from/to central (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-ssh/2.1/wagon-ssh-2.1.pom.
Return code is:501, ReasonPhrase:HTTPS Required. -> [Help 2]
等待 Jenkins 完成data[ERROR]
插件 org.apache.maven.plugins:maven-clean-plugin:2.4.1
或其依赖项之一无法解析:
无法读取 org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
:
的工件描述符无法将工件 org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1
从/传输到中央 (http://repo.maven.apache.org/maven2):
传输文件失败:http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom.
返回码为: 501 , ReasonPhrase:HTTPS 必需.->[帮助1]
Waiting for Jenkins to finish collecting data[ERROR]
Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1
or one of its dependencies could not be resolved:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
:
Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1
from/to central (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom.
Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]
推荐答案
观察到的错误的原因在 需要中央 501 HTTPS
The reason for the observed error is explained in Central 501 HTTPS Required
自 2020 年 1 月 15 日起,中央存储库不再支持通过纯 HTTP 进行不安全的通信并要求所有请求到存储库的数据通过 HTTPS 加密.
Effective January 15, 2020, The Central Repository no longer supports insecure communication over plain HTTP and requires that all requests to the repository are encrypted over HTTPS.
看起来最新版本的 Maven(在 3.6.0、3.6.1 中尝试过)默认已经在使用 HTTPS URL.
It looks like latest versions of Maven (tried with 3.6.0, 3.6.1) are already using the HTTPS URL by default.
以下是主要存储库切换的日期:
Here are the dates when the major repositories will switch:
从 1 月 13 日开始,您的 Java 构建可能会中断(如果您尚未将 repo 访问权限切换为 HTTPS)
更新:似乎从 maven 3.2.3 maven central 是通过 HTTPS 访问的请参阅 https://stackoverflow.com/a/25411658/5820670
Update: Seems like from maven 3.2.3 maven central is accessed via HTTPS See https://stackoverflow.com/a/25411658/5820670
Maven 变更日志(http://maven.apache.org/docs/3.2.3/release-notes.html)
Maven Change log (http://maven.apache.org/docs/3.2.3/release-notes.html)
这篇关于Maven 依赖项失败并出现 501 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!