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 ):
无法传输文件:
[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 ):
无法传输文件:
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]
推荐答案
从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: 更新:看起来像来自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屋!