Home Maven Maven - What is default location of local repository?

Maven – What is default location of local repository?

A quick guide on how to find where is the Maven’s local repository default path location and how to change it to custom directory location.

The local repository is a directory on the computer where Maven runs. When you build project, it caches remote downloads to reduce network traffic, and also contains temporary build artifacts that you have not yet released.

1. Maven local repository default locations

By default, in all systems, the maven local repository location path is .m2/repository under home user.

WindowsC:\Users\{username}\.m2\repository

Mac/Users/{username}/.m2/repository OR you also can access with ~/.m2/repository

Unix / Linux/home/{username}/.m2/repository OR you also can access with ~/.m2/repository

2. Custom Maven local repository path

2.1. If you wants to change maven local repository location, first of all you need to find maven setup directory. You can find that from command-line in windows echo %MAVEN_HOME%, in Mac/ Linux echo $MAVEN_HOME. Alternatively you can try $ mvn -version command to get the maven setup location.

In Windows:

$ echo %MAVEN_HOME% 

Z:\D\maven\apache-maven-3.6.3

In Linux or Mac:

$ echo $MAVEN_HOME

/home/admin/Documents/apache-maven-3.6.3

2.2. Now, you will find conf directory under setup path. Explore it, you will find settings.xml.

2.3. Open settings.xml, specify value for localrepository property like following and save the file. Your repository location pointed to the specified location.

maven local repository

Note: If the maven local repository not present in the default location path under {username}/.m2, look at localrepository property value in settings.xml. Default repository location might be changed to custom location.

3. Conclusion

In this tutorial, we have seen where is maven local repository located by default and how to configure the custom location to change the default local repository path.

You also might interested in following Maven guides:

  1. Install Maven on Windows
  2. Install Maven on Mac
  3. Install Maven on Ubuntu
  4. Import maven project into Eclipse
  5. Maven run single test
  6. Maven set java version
  7. Maven skip tests
  8. Maven – run java main method

4. References

  1. Maven Settings
  2. Configuring Maven

LEAVE A REPLY

Please enter your comment!
Please enter your name here