为什么 Eclipse 更新 Maven 依赖需要这么长时间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5012567/
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
Why does Eclipse take so long to update Maven dependencies?
提问by Tom
I have a Maven project in my Eclipse workspace. When I start Eclipse, it takes a very long time to update Maven dependencies. It actually seems like it will never finish and while it is doing this update, I can't do anything in Eclipse.
我的 Eclipse 工作区中有一个 Maven 项目。当我启动 Eclipse 时,更新 Maven 依赖项需要很长时间。它实际上似乎永远不会完成,并且在进行此更新时,我无法在 Eclipse 中执行任何操作。
Can anybody help me?
有谁能够帮助我?
采纳答案by crowne
First check all of your dependencies including plugins and children in the dependency tree,
try to replace snapshot versions with release versions,
as snapshot versions will always look for a later update, whereas
release versions are deemed to be stable and updates are not expected for the same version number.
首先检查所有依赖项,包括依赖项树中的插件和子项,
尝试将快照版本替换为发布版本,
因为快照版本将始终寻找以后的更新,而
发布版本被认为是稳定的,并且不需要更新相同的版本号。
Secondly, assuming that you are working on a LAN, I would suggest that you install a local maven repository manager such as Nexus, and then redirect your artifact requests by setting<mirrorOf>*</mirrorOf>
in your ${user.home}/.m2/settings.xml
其次,假设您在 LAN 上工作,我建议您安装一个本地 Maven 存储库管理器,例如Nexus,然后通过<mirrorOf>*</mirrorOf>
在 ${user.home}/.m2/settings.xml 中进行设置来 重定向您的工件请求
This will enable your downloads to be resolved quickly against a local mirror, rather than continually checking against repositories on the internet.
这将使您的下载能够根据本地镜像快速解决,而不是不断检查 Internet 上的存储库。
回答by FrVaBe
If this happens on eclipse start, it is maybe not the dependecy update of your project but the Maven repository index update (as khmarbaise mentioned in his comment).
如果这发生在 eclipse 启动时,它可能不是您项目的依赖更新,而是 Maven 存储库索引更新(如 khmarbaise 在他的评论中提到的)。
You can disable this here: Preferences→ Maven→ Download repository index updates on startup
您可以在此处禁用此功能:首选项→ Maven→启动时下载存储库索引更新
A fresh index offers you an up to date list of dependencies, e.g. in the Add Dependencydialog. But I found it will do if the index is updated manually (as needed) in the Maven RepositoriesView.
新索引为您提供最新的依赖项列表,例如在“添加依赖项”对话框中。但是我发现如果在Maven RepositoriesView 中手动更新索引(根据需要),它会这样做。
Update: Since Eclipse Luna the index update is now disabled by default (see Bug404417).
更新:由于 Eclipse Luna,索引更新现在默认禁用(参见Bug404417)。
回答by Vik18
Even i was facing updating maven dependencies on eclipse startup and eclipse hangup. I found that my workspace directory do not have required permission(full permission). After i set those permission my issue got resolved.
甚至我也面临更新 Eclipse 启动和 Eclipse 挂断的 Maven 依赖关系。我发现我的工作区目录没有必需的权限(完全权限)。在我设置这些权限后,我的问题得到了解决。
回答by TrueDub
Have you set Eclipse to use the local copy of Maven, rather than the built-in one? I've found that to be quicker. Also, make sure Eclipse is pointing to the local copy of your config file.
您是否已将 Eclipse 设置为使用 Maven 的本地副本,而不是内置副本?我发现这样做会更快。此外,请确保 Eclipse 指向您的配置文件的本地副本。
回答by Hrishi Jimage
If it still takes a long time after trying all the other options, create a new workspace and move your projects to the new workspace.
如果在尝试所有其他选项后仍然需要很长时间,请创建一个新工作区并将您的项目移动到新工作区。
回答by Pichitron
If you use a proxy for connect, check in your settings.xml (D:\apache-maven-3.3.3\conf) if you have set correctly the user/password.
如果您使用代理进行连接,如果您已正确设置用户/密码,请检查您的 settings.xml (D:\apache-maven-3.3.3\conf)。
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>XXXX</username>
<password>XXXX</password>
<host>XXXX</host>
<port>8080</port>
<nonProxyHosts>XXXX</nonProxyHosts>
</proxy>
</proxies>