Add Maven repositories for a project in Eclipse?

强颜欢笑 提交于 2020-07-08 03:58:07

问题


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.


回答1:


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>



回答2:


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.




回答3:


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/



来源:https://stackoverflow.com/questions/15429142/add-maven-repositories-for-a-project-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!