How to change maven local repository path in windows

Maven is build and dependency management tool as we all know. It downloads required project dependencies to your local system and include them to your project compilation or run-time as defined. By default maven’s local repository exist on following path :

C:/Documents and Settings<windows username>/.m2/repository

You can change this location to some other location of your choice. This can be done using below steps.

1) For existing maven installation

For existing installation, follow below steps:

  • Navigate to path : C:/Documents and Settings/<current username>/.m2
  • Open file settings.xml in edit mode in some text editor.
  • Open the tag <localRepository>
  • Update the desired path in value of this tag.
  • Congratulations, You are done.

2) For new maven installation

For new installation, follow below steps:

  • From the Windows “Start” button on the menu, select the “Run” menu item. Into the dialog box, enter the command “cmd” and press the “Ok” button. This will open a command window with a shell prompt.
  • Type cd “C:/Documents and Settings/<windows username>”/
  • Type mkdir .m2
  • Type cd .m2
  • Type notepad settings.xml. This will open a new document in Notepad and show you a warning “Cannot find the settings.xml file. Do you want to create a new file?”. Select “Yes”.
  • Enter the following code into the document: <settings><localRepository>D:/mavenrepository</localRepository></settings> (Give here path of your choice)
  • Save the file and close out of notepad.
  • Congrates, You are done.

Happy Learning !!

5 thoughts on “How to change maven local repository path in windows”
  1. Which tag needs to be opened? Tag name has not been specified in existing maven installation case. Kindly specify it.

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

        thank you.

        1. 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.

Note:- In comment box, please put your code inside [java] ... [/java] OR [xml] ... [/xml] tags otherwise it may not appear as intended.

Leave a Reply

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