How to change maven local repository path in windows

Spread the words...Share on Google+3Share on Facebook1Tweet about this on Twitter4Share on LinkedIn1Buffer this pageShare on StumbleUpon0Share on Reddit0

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 !!

Spread the words...Share on Google+3Share on Facebook1Tweet about this on Twitter4Share on LinkedIn1Buffer this pageShare on StumbleUpon0Share on Reddit0

 

 

Give me your email address and whenever I write any tutorial or discuss any java concept, you will receive a little email in your inbox.

Join 2,874 other subscribers

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

Want to ask any question? Or suggest anything?