简体   繁体   English

在 Eclipse 中为项目添加 Maven 存储库?

[英]Add Maven repositories for a project in Eclipse?

How can I add Maven repositories for a project.如何为项目添加 Maven 存储库。 I'm using Eclipse Juno version: Juno Service Release 1 Build id: 20120920-0800 and using Fedora as my OS.我正在使用 Eclipse Juno 版本:Juno Service Release 1 Build id:20120920-0800 并使用 Fedora 作为我的操作系统。

You can include it in your pom.xml .您可以将它包含在您的pom.xml Just add the repositories information inside the <project> tag只需在<project>标签内添加存储库信息

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

You have to add the repository to your settings.xml : Maven Settings Reference .您必须将存储库添加到settings.xmlMaven 设置参考 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.检查 eclipse Window -> Preferences -> Maven -> Installations以查看此文件所在的位置。

You can also add a repository in the pom.xml of your project to make it available for this project only.您还可以在项目的pom.xml中添加一个存储库,使其仅可用于该项目。

For new installation, follow below steps:对于新安装,请按照以下步骤操作:

From the Windows “Start” button on the menu, select the “Run” menu item.从 Windows 菜单上的“开始”按钮中,选择“运行”菜单项。 Into the dialog box, enter the command “cmd” and press the “Ok” button.进入对话框,输入命令“cmd”并按“确定”按钮。 This will open a command window with a shell prompt.这将打开一个带有 shell 提示的命令窗口。

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.这将在记事本中打开一个新文档并显示警告“找不到 settings.xml 文件。 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/来自http://howtodoinjava.com/2013/01/04/how-to-change-maven-local-repository-path-in-windows/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM