Where is Maven local repository ?
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 :
- Unix/Mac OS X – ~/.m2 on
- 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 :







[...] this case, If Maven can’t find your dependency libraries in your Maven local repository, it will try download it from the default Maven central repository, which is [...]
[...] Maven local repository Maven local repository is used to store the project dependency libraries, and the default folder is “.m2″, you may need to change it to another folder. [...]
[...] really magic, Maven will download all the necessary project’s dependency libraries in your Maven’s local repository, all newly created project’s files and folders in your current file path , [...]