Add Maven repositories for a project in Eclipse?

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 (Give here path of your choice)
</localRepository>
</settings> 

Save the file and close out of notepad. Congrates, You are done. Happy Learning !!

from http://howtodoinjava.com/2013/01/04/how-to-change-maven-local-repository-path-in-windows/


You have to add the repository to your settings.xml: Maven Settings Reference. For example:

  <repositories>
    <repository>
      <id>codehausSnapshots</id>
      <name>Codehaus Snapshots</name>
      <releases>
        <enabled>false</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
      </snapshots>
      <url>http://snapshots.maven.codehaus.org/maven2</url>
      <layout>default</layout>
    </repository>
  </repositories>

Check the settings in eclipse Window -> Preferences -> Maven -> Installations to see where this file is located.

You can also add a repository in the pom.xml of your project to make it available for this project only.


You can include it in your pom.xml. Just add the repositories information inside the <project> tag

<repositories>
    <repository>
        <id>maven-restlet</id>
        <name>Public online Restlet repository</name>
        <url>http://maven.restlet.org</url>
    </repository>
</repositories>