18

How can I add Maven repositories for a project. I'm using Eclipse Juno version: Juno Service Release 1 Build id: 20120920-0800 and using Fedora as my OS.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
Savio Mathew
  • 719
  • 1
  • 7
  • 14

3 Answers3

39

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>
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
greenkode
  • 4,001
  • 1
  • 26
  • 29
5

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.

Kai
  • 38,985
  • 14
  • 88
  • 103
  • Did that — but it did not work. And I dont't knwo why. Any hints on what could go wrong? – Martin Jan 23 '14 at 09:27
  • I had to "Select profile" for given project in eclipse, then the dependency has been downloaded - right click on project, Maven, Select Maven Profiles, select default and OK. – Jirka Meluzin Feb 07 '17 at 19:33
1

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/

Gilles Bodart
  • 594
  • 1
  • 10
  • 27