Maven dependencies are failing with a 501 error

前端 未结 25 3223
南旧
南旧 2020-11-22 06:28

Recently Maven build jobs running in Jenkins are failing with the below exception saying that they couldn\'t pull dependencies from Maven Central

相关标签:
25条回答
  • 2020-11-22 07:27

    Add the following repository in pom.xml.

    <project>
    ...
        <repositories>
            <repository>
                <id>central</id>
                <name>Maven Plugin Repository</name>
                <url>https://repo1.maven.org/maven2</url>
                <layout>default</layout>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
    ...
    </project>
    
    
    0 讨论(0)
  • 2020-11-22 07:28

    The error:

    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.

    Root cause analysis:

    Maven central is expecting that the clients use https, but the client is making plain HTTP request only.

    Therefore, the request for downloading the package named 'wagon-ssh-2.1.pom' had failed.

    How to fix the problem?

    Replace the URL "http://repo.maven.apache.org/maven2"

    with "https://repo.maven.apache.org/maven2"

    in pom.xml file or build.gradle file of the project.

    0 讨论(0)
  • 2020-11-22 07:28

    I downloaded latest eclipse and tarted to use from here https://www.eclipse.org/downloads/packages/release/ which resolved my problem.

    0 讨论(0)
  • 2020-11-22 07:29

    Maven is moving to HTTPS and disabling HTTP access

    Short story, from January 15, 2020, Maven Central repository is not longer supporting HTTP connections (other repositories are doing the same). Therefore, you will indicate your Maven/Gradle settings to use an HTTPS URL.

    Solution:

    You can choose one of the following three approaches.

    1. Add a repository in your project´s pom.xml file

      <project>
      ...
        <repositories>
          <repository>
            <id>central maven repo</id>
            <name>central maven repo https</name>
            <url>https://repo.maven.apache.org/maven2</url>
          </repository>
        </repositories>
      </project>
      
    2. Add the repository into a profile in the settings.xml file.

      <profile>
        <id>my profile</id>
        <repositories>
          <repository>
            <id>central maven repo</id>
            <name>central maven repo https</name>
            <url>https://repo.maven.apache.org/maven2</url>
            </repository>
        </repositories>
      </profile>
      
    3. Update you maven version to a new one that uses https values as default. The lastest one at this moment 3.6.3 Download here

    For Gradle:

    Only replace the URL for the HTTPS version.

    repositories {
       maven { url "https://repo.maven.apache.org/maven2" }
    }
    
    0 讨论(0)
  • 2020-11-22 07:30

    Update the central repository of Maven and use https instead of http.

    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    
    0 讨论(0)
  • 2020-11-22 07:30

    If you are using Netbeans older version, you have to make changes in maven to use https over http

    Open C:\Program Files\NetBeans8.0.2\java\maven\conf\settings.xml and paste below code in between mirrors tag

    <mirror>
    <id>maven-mirror</id>
    <name>Maven Mirror</name>
    <url>https://repo.maven.apache.org/maven2</url>
    <mirrorOf>central</mirrorOf>
    </mirror>
    

    It will force maven to use https://repo.maven.apache.org/maven2 url.

    0 讨论(0)
提交回复
热议问题