Javatpoint Logo
Javatpoint Logo

Maven Repository

A maven repository is a directory of packaged JAR file with pom.xml file. Maven searches for dependencies in the repositories. There are 3 types of maven repository:

  1. Local Repository
  2. Central Repository
  3. Remote Repository

Maven searches for the dependencies in the following order:

Local repository then Central repository then Remote repository.

maven repositories

If dependency is not found in these repositories, maven stops processing and throws an error.

1) Maven Local Repository

Maven local repository is located in your local system. It is created by the maven when you run any maven command.

By default, maven local repository is %USER_HOME%/.m2 directory. For example: C:\Users\SSS IT\.m2.

maven local repository

Update location of Local Repository

We can change the location of maven local repository by changing the settings.xml file. It is located in MAVEN_HOME/conf/settings.xml, for example: E:\apache-maven-3.1.1\conf\settings.xml.

Let's see the default code of settings.xml file.

<settings xmlns="" 
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   | Default: ${user.home}/.m2/repository


Now change the path to local repository. After changing the path of local repository, it will look like this:

<settings xmlns="" 

As you can see, now the path of local repository is e:/mavenlocalrepository.

2) Maven Central Repository

Maven central repository is located on the web. It has been created by the apache maven community itself.

The path of central repository is:

The central repository contains a lot of common libraries that can be viewed by this url

3) Maven Remote Repository

Maven remote repository is located on the web. Most of libraries can be missing from the central repository such as JBoss library etc, so we need to define remote repository in pom.xml file.

Let's see the code to add the jUnit library in pom.xml file.

<project xmlns="" 



  <name>Maven Quick Start Archetype</name>



You can search any repository from Maven official website

Next TopicMaven pom.xml file

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA