3

Need Efficient Solution for moving to HTTPS for mvn clean install build success

Tried following solutions at my end

  • Added following settings.xml in ~/.m2/ folder. Tried Profiling options also.

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              https://maven.apache.org/xsd/settings-1.0.0.xsd">
          <localRepository>${user.home}/.m2/repository</localRepository>
          <interactiveMode/>
          <offline/>
          <pluginGroups/>
          <servers/>
                    <mirrors>
                         <mirror>
                          <id>central-repository</id>
                          <name>Maven Repository HTTPS</name>
                          <url>https://repo1.maven.org/maven2</url>
                          <mirrorOf>central</mirrorOf>
                        </mirror>
                         <mirror>
                          <id>central-spring-repository</id>
                          <name>Spring Repository HTTPS</name>
                          <url>https://repo.spring.io</url>
                          <mirrorOf>springcentral</mirrorOf>
                        </mirror>
                        <mirror>
                          <id>organisation-repo1</id>
                          <name>org-repo1</name>
                          <url>http://org.maven.com/repo1</url>
                          <mirrorOf>repo1</mirrorOf>
                        </mirror>
                        <mirror>
                          <id>organisation-repo2</id>
                          <name>org-repo2</name>
                          <url>http://org.maven.com/repo2</url>
                          <mirrorOf>repo2</mirrorOf>
                        </mirror>
                     </mirrors>
          <proxies/>
          <profiles/>
           <activeProfiles/>
    </settings>
    

Still faced some issues for internal jars dependencies in the project.

Failed to read artifact descriptor for com.netflix.hystrix:hystrix-core:jar:1.5.13: Could not transfer artifact com.netflix.hystrix:hystrix-core:pom:1.5.13 from/to cxf-repo (http://repo1.maven.org/maven2/): Transfer failed for http://repo1.maven.org/maven2/com/netflix/hystrix/hystrix-core/1.5.13/hystrix-core-1.5.13.pom 501 HTTPS Required

  • Added following in pom.xml

          <repositories>
            <repository>
                <id>central-maven</id>
                <name>central https Releases</name>
                <url>https://repo.maven.apache.org/maven2</url>
            </repository>
            <repository>
                <id>central-spring</id>
                <name>central spring https Releases</name>
                <url>https://repo.spring.io</url>
            </repository>
          <repositories>
    

Have read this doc for maven central repo movement to HTTPS https://blog.sonatype.com/central-repository-moving-to-https but couldn't get any proper resolution for internal dependency issue.

Some dependencies in my case are still calling http url's of central and spring maven

karans123
  • 796
  • 6
  • 8
  • take backup of m2 folder and create empty .m2 folder . clean maven repo and start from scratch. I know it is time taking process. but it may help ! – Mandar Dharurkar Jan 20 '20 at 02:39
  • Or i would suggest to mvn generate dependency tree in your project that will tell us exactly which component is calling this and remove that dependency from m2 folder – Mandar Dharurkar Jan 20 '20 at 02:41
  • Go through this and find a solution that works for you. https://stackoverflow.com/questions/59763531/maven-dependencies-are-failing-with-a-501-error I used the answer from Sumeet Vishwas and changing maven to use the latest version for netbeans. – Sanal S Jan 27 '20 at 04:21

2 Answers2

3

Either upgrade your Maven version or

Restrict the current Maven version to use HTTPS links by modifying your POM:

Include the following code in pom.xml of your project.

<project>
  ...
<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

taking a backup of .m2 folder and doing clean and install worked for me.

Sekhar T
  • 11
  • 2