Maven https repository

Maven HTTPS Support is launched and now your maven tool can download the dependency file over https from the Maven central repository. Check this tutorial to know about confirming the https access setting in your maven configuration file.

Maven https repository

Maven https repository access available

Now there is access to the maven central repository over the https. The Sonatype Operations team has done a wonderful in very short time for setting up the certificates and other setup. Now developers can configure the Maven to download the dependencies over https from the Maven central repository. In this tutorial will show you how you can configure it in your existing application.

The Maven Central Repository can be accessed over https through variety of tools being used for the development of the Java based applications. Here is the URLs to access the repository:

  • HTTP: http://repo1.maven.org/maven2
  • HTTPS: https://repo1.maven.org/maven2

It is advisable to use the local repository manager in your organization to save the bandwidth and fast access of the dependencies. You can connect all your project to the local repository and the repository manager will manage the unavailable dependencies from the Maven Central Repository. You can use the Artifactory for managing the the local repository. Other option of the local repository sever is Sonatype Nexus which you can use in your organization.

maven repositories over https

Here is the configuration details to be added in various tools to access the https repository.

Apache Maven

In case of Maven build tool you should add the following code in the pom.xml file:

      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>

Apache Ivy (and Apache Ant)

In case of the Apache Ivy (and Apache Ant) tools you can add the following ivysettings.xml file to access the repository over https:

<ivysettings>
  <settings defaultResolver="chain" />
  <resolvers>
    <chain name="chain">
      <ibiblio name="securedcentral" m2compatible="true" root="https://repo1.maven.org/maven2" />
    </chain>
  </resolvers>
</ivysettings>

Eclipse Aether (and Apache Ant)

In case of Eclipse Aether (and Apache Ant) tool following settings can be used to access the repository over https:

<remoterepo id="securecentral" url="https://repo1.maven.org/maven2">
    <releases enabled="true" updates="daily" checksums="fail"/>
    <snapshots enabled="false"/>
</remoterepo>

Gradle

In case of Gradle following configuration can be used:

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

Check more tutorials of Maven 3 at our Maven 3 tutorials section.