Maven local repository location & how to change it?

In this tutorial, learn to change maven local repository location. Maven is build and dependency management tool. It downloads required project dependencies to our local system and include them to project compilation or run-time as defined.

1. Maven’s default local repository location

By default maven’s local repository exist on ‘${user.home}/.m2/repository’. In different operating systems, these path are resolved to –

Windows 7: 		C:/Documents and Settings/<username>/.m2/repository
Windows 10:		C:/Users/<username>/.m2/repository
Linux: 			/home/<username>/.m2/repository
Mac: 			/Users/<username>/.m2/repository

We can change local repository location to some other location of our choice.

2. Change maven local repository location

Maven is distributed as archive folder. Generally, developers download the maven and extract it their workstation.

After you have downloaded the maven, follow given simple steps to change maven local repository location to some other path.

  • Navigate to path {M2_HOME}\conf\ where M2_HOME is maven installation folder.
  • Open file settings.xml in edit mode in some text editor.
  • Fine the tag <localRepository>
  • Update the desired path in value of this tag. Save the file.
    	<settings xmlns=""
    	  <!-- localRepository
    	   | The path to the local repository maven will use to store artifacts.
    	   | Default: ${user.home}/.m2/repository -->
  • Congratulations, You are done.

    Maven local repository path
    Maven local repository path

Happy Learning !!

Was this post helpful?

Join 7000+ Fellow Programmers

Subscribe to get new post notifications, industry updates, best practices, and much more. Directly into your inbox, for free.

7 thoughts on “Maven local repository location & how to change it?”

  1. I had modified the settings.xml in {M2_HOME}\conf\ but maven ignored it, to resolve that just copy that settings.xml to {user.home}/.m2/

  2. Which tag needs to be opened? Tag name has not been specified in existing maven installation case. Kindly specify it.

      • where have you corrected …….? I m not getting right way to find the settings.xml file in repository plz………make it clear ?

        thank you.

        • The content is updated. I again verified it. It you are installing it first time, OR you don’t have the settings.xml file in it’s location then create a new file with name “settings.xml”. Location of file will be C:/Documents and Settings/<current username>/.m2

          Current username is your windows username e.g. admin.


Leave a Comment


A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.