Add Maven repositories for a project in Eclipse?
Asked Answered
T

3

19

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.

Toomin answered 15/3, 2013 at 9:49 Comment(0)
E
40

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>
Eggbeater answered 15/3, 2013 at 12:56 Comment(3)
Could you please tell me what should come exactly in ID & Name tagHautrhin
What is pom.xml?Kinchen
That's great if you're into manually editing the pom. But shouldn't there be a tab in the UI that can create/edit this section, just like the tab for Dependencies?Weighted
D
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.

Diphyodont answered 15/3, 2013 at 10:28 Comment(2)
Did that — but it did not work. And I dont't knwo why. Any hints on what could go wrong?Finegrain
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.Aseity
T
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/

Trophic answered 17/3, 2015 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.