在 Eclipse 中为项目添加 Maven 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15429142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add Maven repositories for a project in Eclipse?
提问by Savio Mathew
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.
如何为项目添加 Maven 存储库。我正在使用 Eclipse Juno 版本:Juno Service Release 1 Build id:20120920-0800 并使用 Fedora 作为我的操作系统。
回答by greenkode
You can include it in your pom.xml
. Just add the repositories information inside the <project>
tag
您可以将其包含在您的pom.xml
. 只需在<project>
标签内添加存储库信息
<repositories>
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.org</url>
</repository>
</repositories>
回答by Kai
You have to add the repository to your settings.xml
: Maven Settings Reference. For example:
您必须将存储库添加到您的settings.xml
:Maven 设置参考。例如:
<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
您的项目中添加一个存储库,使其仅可用于该项目。
回答by Gilles Bodart
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.
从 Windows 菜单上的“开始”按钮中,选择“运行”菜单项。进入对话框,输入命令“cmd”并按“确定”按钮。这将打开一个带有 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. Do you want to create a new file?”. Select “Yes”. Enter the following code into the document:
这将在记事本中打开一个新文档并显示警告“找不到 settings.xml 文件。您要创建一个新文件吗?”。选择“是”。在文档中输入以下代码:
<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/