Maven local repository is used to store all your projects’ dependency libraries (plugin jars and other files which downloaded by Maven), . In simple, when you use Maven to build your project, it will automatically download all dependency libraries into your Maven local repository.

Maven local repository is default to home directory :

  1. Unix/Mac OS X – ~/.m2 on
  2. Windows – C:\Documents and Settings\username\.m2 on Windows

Often times, you need to change the default location for maintainability purpose, after all, the .m2 is not a meaningful name.

1. Maven configuration file

Maven local repository is defined in the Maven’s configuration file, for example, {M2_HOME}\conf\setting.xml.

2. Edit it “setting.xml”

Find the following “localRepository” pattern, and define your new Maven local repository inside the “<localRepository>” element like this :

<settings>
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ~/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
 
<localRepository>D:/maven_repo</localRepository>

3. Saved it

Done, your new Maven local repository is now changed to D:/maven_repo, all the future project’s dependency libraries or related files will be downloaded into this folder. See following folder :

Maven local repository
Note : You can find more similar articles at - Maven Tutorials