18

如何为项目添加 Maven 存储库。我正在使用 Eclipse Juno 版本:Juno Service Release 1 Build id: 20120920-0800 并使用 Fedora 作为我的操作系统。

4

3 回答 3

38

您可以将其包含在您的pom.xml. 只需在<project>标签内添加存储库信息

<repositories>
    <repository>
        <id>maven-restlet</id>
        <name>Public online Restlet repository</name>
        <url>http://maven.restlet.org</url>
    </repository>
</repositories>
于 2013-03-15T12:56:16.220 回答
4

您必须将存储库添加到您的settings.xmlMaven 设置参考。例如:

  <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>

检查 eclipse Window-> Preferences-> Maven->中的设置Installations以查看此文件所在的位置。

您还可以在pom.xml项目中添加一个存储库,使其仅可用于该项目。

于 2013-03-15T10:28:00.130 回答
1

对于全新安装,请按照以下步骤操作:

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/

于 2015-03-17T12:53:43.473 回答