Maven dependencies are failing with a 501 error

前端 未结 25 3222
南旧
南旧 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:24

    I was added following code segment to setting.xml and it was resolved the issue,

    <mirrors>
        <mirror>
            <id>maven-mirror</id>
            <name>Maven Mirror</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
    
    0 讨论(0)
  • 2020-11-22 07:25

    This error occured to me too. I did what Muhammad umer said above. But, it only solved error for spring-boot-dependencies and spring-boot-dependencies has child dependencies. Now, there were 21 errors. Previously, it was 2 errors. Like this:

    Non-resolvable import POM: Could not transfer artifact org.springframework.cloud:spring-cloud-dependencies:pom:Hoxton.SR3 from/to central
    

    and also https required in the error message.

    I updated the maven version from 3.2.2 to 3.6.3 and java version from 8 to 11. Now, all errors of https required are gone.

    To update maven version

    1. Download latest maven from here: download maven
    2. Unzip and move it to /opt/maven/
    3. Set the path export PATH=$PATH:/opt/maven/bin
    4. And, also remove old maven from PATH
    0 讨论(0)
  • 2020-11-22 07:26

    Using Ubuntu 16.04, java 1.8.0_201.

    I un-installed old maven and installed Maven 3.6.3, still got this error that Maven dependencies are failing with a 501 error.

    Realized it could be a truststore/keystore issue associated with requiring https. Found that you can now configure -Djavax options using a jvm.config file, see: https://maven.apache.org/configure.html.

    As I am also using Tomcat I copied the keystore & truststore config from Tomcat (setenv.sh) to my jvm.config and then it worked!

    There is also an option to pass the this config in 'export MAVEN_OPTS' (when using mvn generate) but although this stopped the 501 error it created another: it expected a pom file.

    Creating a separate jvm.config file works perfectly, just put it in the root of your project.

    Hopefully this helps someone, took me all day to figure it out!

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

    Same issue is also occuring for jcenter.

    From 13 Jan 2020 onwards, Jcenter is only available at HTTPS.

    Projects getting their dependencies using the same will start facing issues. For quick fixes do the following in your build.gradle

    instead of

    repositories {
    jcenter ()
    //others
    }
    

    use this:

    repositories {
    jcenter { url "http://jcenter.bintray.com/"}
    //others
    }
    
    0 讨论(0)
  • 2020-11-22 07:27

    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.

    If you're receiving this error, then you need to replace all URL references to Maven Central with their canonical HTTPS counterparts.

    (source)

    We have made the following changes in my project's build.gradle:

    Old:

    repositories {
       maven { url "http://repo.maven.apache.org/maven2" }
    }
    

    New:

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

    I have the same issue, but I use GitLab instead of Jenkins. The steps I had to do to get over the issue:

    1. My project is in GitLab so it uses the .yml file which points to a Docker image I have to do continuous integration, and the image it uses has the http://maven URLs. So I changed that to https://maven.
    2. That same Dockerfile image had an older version of Maven 3.0.1 that gave me issues just overnight. I updated the Dockerfile to get the latest version 3.6.3
    3. I then deployed that image to my online repository, and updated my Maven project ymlfile to use that new image.
    4. And lastly, I updated my main projects POM file to reference https://maven... instead of http://maven

    I realize that is more specific to my setup. But without doing all of the steps above I would still continue to get this error message Return code is: 501 , ReasonPhrase:HTTPS Required

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