java - 对 http ://repo1. maven.org/maven2/的请求返回 501 HTTPS 必需状态和正文

标签 java maven

这个问题在这里已经有了答案:





Maven dependencies are failing with a 501 error

(27 个回答)


去年关闭。




截至 2020 年 1 月 15 日,我在向中央存储库提出请求时收到以下回复:

Requests to http://repo1.maven.org/maven2/ return a 501 HTTPS Required status and a body:

501 HTTPS Required. 
Use https://repo1.maven.org/maven2/
More information at https://links.sonatype.com/central/501-https-required
Requests to http://repo.maven.apache.org/maven2/ return a 501 HTTPS Required status and a body:

501 HTTPS Required. 
Use https://repo.maven.apache.org/maven2/
More information at https://links.sonatype.com/central/501-https-required

如何满足此要求以便我可以重新访问 Central?

我在控制台中收到此错误
    [INFO] Scanning for projects...
    [INFO] 
    [INFO] ----------------------------<  >----------------------------
    [INFO] Building demo 0.0.1-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] Downloading from : http://repo1.maven.org/maven2/org/mongodb/mongo-java-driver/3.12.0/mongo-java-driver-3.12.0.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  11.136 s
    [INFO] Finished at: 2020-01-16T15:27:53+05:30
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project demo: Could not resolve dependencies for project com.tcs:demo:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.mongodb:mongo-java-driver:jar:3.12.0: Failed to read artifact descriptor for org.mongodb:mongo-java-driver:jar:3.12.0: Could not transfer artifact org.mongodb:mongo-java-driver:pom:3.12.0 from/to central (http://repo1.maven.org/maven2/): Failed to transfer http://repo1.maven.org/maven2/org/mongodb/mongo-java-driver/3.12.0/mongo-java-driver-3.12.0.pom. Error code 501, HTTPS Required -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace ``of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

并使用站点插件:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:2.2:site (default-site) on project my-proj: SiteToolException: The site descriptor cannot be resolved from the repository: ArtifactResolutionException: Unable to locate site descriptor: Could not transfer artifact org.x.y:name:xml:site_en:3.5.1.b550 from/to central (http://repo1.maven.org/maven2): Transfer failed for http://repo1.maven.org/maven2/org/x/y/3.5.1.b550/name-3.5.1.b550-site_en.xml 501 HTTPS Required

最佳答案

自 2020 年 1 月 15 日起,中央存储库不再支持通过普通 HTTP 进行的不安全通信,并要求对存储库的所有请求都通过 HTTPS 进行加密。

如果您收到此错误,则需要将所有对 Maven Central 的 URL 引用替换为其规范的 HTTPS 对应项:

替换 http://repo1.maven.org/maven2/https://repo1.maven.org/maven2/

替换 http://repo.maven.apache.org/maven2/https://repo.maven.apache.org/maven2/

如果由于任何原因您的环境不支持 HTTPS,您可以选择使用我们专用的不安全端点 http://insecure.repo1.maven.org/maven2/

有关转向 HTTPS 的更多背景信息,请参阅 https://blog.sonatype.com/central-repository-moving-to-https .

关于java - 对 http ://repo1. maven.org/maven2/的请求返回 501 HTTPS 必需状态和正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59764749/

相关文章:

android - 覆盖来自在 Android 中有翻译的模块/库的字符串资源

java - Vaadin DateField 验证不显示验证错误

java - 如何获取泛型类型 T 的类实例?

java - Guice AssistedInject 不会注入(inject)工厂

java - HttpURLConnection:是否需要调用connect()?

spring - 错误尝试在 spring mvc 中使用 maven 从 WSDL 生成类

java - Maven 依赖声明分类器属性的目的是什么?

java - JAVA获取从设定日期起一周内所有日期的列表

maven - 为什么 Groovy/Grape 不能解析来自 Maven Central 的 Artifact ?

java - Maven - 查看依赖树而不构建项目