Share on Google+Share on Google+

Change Local Repository

Advertisement
In this section, you will learn to change the default local repository of Maven using setting.xml configuration file.

Change Local Repository

In this section, you will learn to change the default local repository of Maven using setting.xml configuration file.

What is local repository of Maven ?

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.


Where to find default local repository of Maven (.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


How to change the default local repository of Maven ?

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.

Advertisements

Posted on: July 12, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Comments:0