Maven Central Repository is moving to HTTPS and disablig HTTP access

Advertisements

If you are getting the following error when you are building your Java project using maven or gradle
Failed to transfer file: http://repo.maven.apache.org/maven2/<some/dependency/artifact>.pom Return code is: 501 , ReasonPhrase:HTTPS Required.

And you are thinking what happened, I haven’t changed anything in my project, no new dependencies, or repositories. The answers is that, you haven’t changed anything.

Do not panic! Effective January 15, 2020, the Central Repository is not longer supporting communication over HTTP and it requires requests to the repository must be over HTTPS.

What Do I need to do ?

The solution is very easy, you just need to replace the urls to maven central repository (and maybe other main repositories) to https instead of http. That’s all!!!

Replace: http://repo1.maven.org/maven2/
To: https://repo1.maven.org/maven2/

Replace: http://repo.maven.apache.org/maven2/
To: https://repo.maven.apache.org/maven2/

In case, you have never defined the repositories url and you are using the default values, you just need to add the new repositories with https.

How to add new repositories ?

There are 2 options, you can do it in your project’s pom.xml file or you can do it in settings.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>
Advertisements

For settings.xml file, you will need to create a profile and add the above code into that profile. Remember to activate that profile.

I prefer the option of adding the repository into my pom.xml in the project.

What about Gradle?

Since gradle also uses the Maven Central Repository, you will need to update the values in the repository:

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

Other Repositories that will disable HTTP

These are some other repositories the are also moving to https.

RepositoryURLDate
Spring (Pivotal) http://repo.spring.io January 15, 2020
Gradle http://repo.gradle.org January 15, 2020
JFrog Bintray http://jcenter.bintray.com January 13, 2020

References

Advertisements

6 comments

Leave a Reply

Your email address will not be published. Required fields are marked *