最近在 Jenkins 中运行的 Maven 构建作业失败,出现以下异常,表示它们无法从 Maven Central 中提取依赖项,应该使用 HTTPS。我不确定如何将请求从 HTTP 更改为 HTTPS。有人可以指导我解决这个问题吗?
[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]
Waiting for Jenkins to finish collecting
data[ERROR]
Pluginorg.apache.maven.plugins:maven-clean-plugin:2.4.1
or one of its dependencies could not be resolved:
Failed to read artifact descriptor fororg.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
:
Could not transfer artifactorg.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]
最佳答案
观察到的错误的原因在 Central 501 HTTPS Required 中解释。
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。
以下是主要存储库切换的日期:
Your Java builds might break starting January 13th (if you haven't yet switched repo access to HTTPS)
更新:似乎从 maven 3.2.3 maven central 是通过 HTTPS 访问的
见 https://stackoverflow.com/a/25411658/5820670
Maven 更改日志
( http://maven.apache.org/docs/3.2.3/release-notes.html )
关于java - Maven 依赖项失败并出现 501 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59763531/