Home > Java > javaTutorial > Why Do My Maven Dependencies Fail with a 501 Error?

Why Do My Maven Dependencies Fail with a 501 Error?

Mary-Kate Olsen
Release: 2024-12-13 05:37:18
Original
467 people have browsed it

Why Do My Maven Dependencies Fail with a 501 Error?

Maven Dependencies Fail with 501 Error

Recent Maven build jobs in Jenkins have encountered failures due to the following exception:

[ERROR] Failed to transfer artifact org.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.
Copy after login

This error indicates that Maven is attempting to retrieve dependencies from Maven Central using HTTP, which is no longer supported.

Solution

As of January 15, 2020, Maven Central requires HTTPS for all requests. To resolve the issue, ensure that your Maven settings use the HTTPS URL for Maven Central:

<settings>
  <profiles>
    <profile>
      <id>central-https</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo.maven.apache.org/maven2</url>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>
Copy after login

Activate the "central-https" profile when running Maven commands, for example:

mvn -P central-https package
Copy after login

Additionally, ensure that the latest version of Maven (at least 3.6.0) is being used, as it includes updated default settings for HTTPS usage.

The above is the detailed content of Why Do My Maven Dependencies Fail with a 501 Error?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template