eclipse 和 maven 全球中央存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14247997/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:46:53  来源:igfitidea点击:

eclipse and maven global central repository

eclipsemaven

提问by pepito apellido

pictureHello!

图片你好!

My question is related to eclipse and maven integration, maven repositories and global index update from central mirror.

我的问题与 eclipse 和 maven 集成、maven 存储库和来自中央镜像的全局索引更新有关。

The quiz is:
Let's supose that I don't have specified any special mirror, nor
{maveninstallationfolder}\conf\settings.xml
neither
{user-home}.m2\settings.xml

测验是:
让我们supose,我不指定任何特殊的镜子,也不
{maveninstallationfolder} \的conf \ settings.xml的
既不是
{用户家} .m2目录\ settings.xml中

So then, why or how eclipse 'maven repositories' tab decides to fetch central at
repo.maven.apache.org/maven2
or
repo1.maven.org/maven2
?

那么,为什么或如何 eclipse ' maven repositories' 选项卡决定在
repo.maven.apache.org/maven2

repo1.maven.org/maven2获取中心

Which settings.xml is reloading eclipse when I click on 'reload settings' button?

当我单击“重新加载设置”按钮时,哪个 settings.xml 正在重新加载 Eclipse ?

I ask this because I have two different eclipse installations ('indigo' at work, 'juno' at home).
At home when I click on 'update index' it works ok. It updates it from central mirror repo.maven.apache.org
At work, doing the same operation it always fails trying to update it from repo1.maven.org(I don't know neither I care if because of firewall or proxy issues)
I would like to know how to change it and force it to fetch it from one or another.

我问这个是因为我有两个不同的日食装置('indigo' 在工作,'juno' 在家里)。
在家里,当我点击“更新索引”时,它工作正常。它从中央镜像repo.maven.apache.org更新它
在工作中,执行相同的操作它总是无法尝试从repo1.maven.org更新它(我不知道我也不关心是否因为防火墙或代理问题)
我想知道如何更改它并强制它从一个或另一个中获取它。

I attach a picture to clarify

我附上一张图片来澄清

thanks in advance

提前致谢

回答by Lee Meador

If you have a preferred central repo or if you are using a company maven proxy (like nexus or artifactory) you can set it in the user settings.xml. You may have to create this file. This is normally in ~/.m2on linux or c:\Users\YourUser\.m2on Win7 or c:\Documents and Settings\YourUser\.m2on WinXP (IIRC). Note that this is the same place as your local repostitory base folder.

如果您有首选的中央存储库,或者您使用的是公司 Maven 代理(如 nexus 或 artifactory),则可以在用户 settings.xml 中进行设置。您可能必须创建此文件。这通常在~/.m2linux 或c:\Users\YourUser\.m2Win7 或c:\Documents and Settings\YourUser\.m2WinXP (IIRC) 上。请注意,这与您的本地存储库基本文件夹位于同一位置。

When I create a new settings.xml on a machine that doesn't have one, I go to the maven2 documentations web pages, find the sample settings.xml that is there and copy it to a new file I create.

当我在没有设置的机器上创建新的 settings.xml 时,我会转到 maven2 文档网页,找到那里的示例 settings.xml 并将其复制到我创建的新文件中。

There is a global settings.xmlin $M2_HOME\confbut it usually isn't changed from the default. It does document all the sections you can add to your settings.xmlsince both have the same sections. (If you are using the embedded version of maven in something like MyEclipse or the maven eclipse plugin, I don't know where they put it.)

有一个全局settings.xmlin$M2_HOME\conf但它通常不会从默认值更改。它确实记录了您可以添加到您的所有部分,settings.xml因为它们都具有相同的部分。(如果你在 MyEclipse 或 maven eclipse 插件之类的东西中使用嵌入式版本的 maven,我不知道他们把它放在哪里。)

For another question, if you need to configure Maven to use a corporate proxy to get out of the company network to maven central, you can put that information in your user settings.xmlfile--the same one you create to set the URL to use.

对于另一个问题,如果您需要配置 Maven 以使用公司代理离开公司网络到 Maven 中心,您可以将该信息放在您的用户settings.xml文件中——与您创建的用于设置要使用的 URL 的文件相同。

You may have different versions of Maven running on the two machines. That would explain the different names for central. But the two names both point to the same place.

您可能在两台机器上运行不同版本的 Maven。这将解释中央的不同名称。但是这两个名字都指向同一个地方。