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