In this section, you will learn to change the default local repository of Maven using setting.xml configuration file.
Maven local repository is used to store the entire dependency libraries of your project. When you try to build a project using Maven , it checks the pom.xml file and download all the project's dependency libraries from maven central repository, mentioned in the pom.xml, into your Maven local repository. The default name of the Maven's local repository is .m2.
If you are using Windows XP, this should be under :
<root>\Documents and Settings\<login-username>\.m2
Ex.:- C:\Documents and Settings\roseindia\.m2
If you are using Window 7 , you can find it under :
<root>\Users\<login-username>\.m2
Ex. :- C:\Users\roseindia\.m2
If you are using Unix/Mac OS X, you can find it under :
~/.m2
You can change the default local repository of Maven (.m2) by configuring new Maven's local repository using <localRepository> element in settings.xml as follows :
Note :You can find settings.xml inside {M2_HOME}\conf\settings.xml, ex.:-C:\apache-maven-2.2.1\conf\settings.xml.
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>D:/maven/repo</localRepository> </settings>
The new local repository is D:\maven\repo and now it will store the entire dependency libraries of your project.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Change Local Repository
Post your Comment