Java 如何在 Eclipse 中更新 Maven 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2555845/
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
How to update maven repository in Eclipse?
提问by Stephane Grenier
Assuming you're already using the m2eclipse plugin, what can you do when it doesn't update the dependencies to the latest in your repo?
假设您已经在使用m2eclipse 插件,当它没有将依赖项更新到您的存储库中的最新版本时,您可以做什么?
For example, on the command line, you can just add the -U
flag as in
例如,在命令行上,您可以添加如下-U
标志
mvn clean install -U
…to force the dependencies to be updated. Is there something like this within Eclipse? (It doesn't always seem to pick up the latest updates.)
...强制更新依赖项。Eclipse 中有这样的东西吗?(它似乎并不总是获取最新的更新。)
采纳答案by Pascal Thivent
You can right-clickon your project then Maven > Update Project..., then select Force Update of Snapshots/Releasescheckbox then click OK.
您可以右键单击您的项目,然后Maven > Update Project...,然后选择Force Update of Snapshots/Releases复选框,然后单击 OK。
回答by Eugene Ryzhikov
Right-click on your project and choose Maven > Update Snapshots
. In addition to that you can set "update Maven projects on startup" in Window > Preferences > Maven
右键单击您的项目并选择Maven > Update Snapshots
。除此之外,您可以设置“启动时更新 Maven 项目”Window > Preferences > Maven
UPDATE: In latest versions of Eclipse:
Maven > Update Project
. Make sure "Force Update of Snapshots/Releases" is checked.
UPDATE:在Eclipse的最新版本:
Maven > Update Project
。确保选中“强制更新快照/版本”。
回答by Roland Schneider
In newer versions of Eclipse that use the M2E plugin it is:
在使用 M2E 插件的较新版本的 Eclipse 中,它是:
Right-click on your project(s) --> Maven --> Update Project...
右键单击您的项目 --> Maven --> 更新项目...
In the following dialog is a checkbox for forcing the update ("Force Update of Snapshots/Releases")
在下面的对话框中是一个用于强制更新的复选框(“强制更新快照/发布”)
回答by lkisac
Sometimes the dependencies don't update even with Maven->Update Project->Force Update option checked using m2eclipse plugin.
有时即使使用 m2eclipse 插件检查 Maven->Update Project->Force Update 选项,依赖项也不会更新。
In case it doesn't work for anyone else, this method worked for me:
如果它对其他人不起作用,则此方法对我有用:
mvn eclipse:eclipse
This will update your .classpathfile with the new dependencies while preserving your .projectsettings and other eclipse config files.
mvn eclipse:eclipse
这将使用新的依赖项更新您的.classpath文件,同时保留您的.project设置和其他 eclipse 配置文件。
If you want to clear your old settings for whatever reason, you can run:
如果您想清除旧设置,无论出于何种原因,您都可以运行:
mvn eclipse:clean
mvn eclipse:eclipse
mvn eclipse:cleanwill erase your old settings, then mvn eclipse:eclipsewill create new .project, .classpathand other eclipse config files.
mvn eclipse:clean
mvn eclipse:eclipse
mvn eclipse:clean将清除您的旧设置,然后mvn eclipse:eclipse将创建新的.project、.classpath和其他 eclipse 配置文件。
回答by Nitin Dandriyal
If Maven update snapshot doesn't work and if you have Spring Tooling, one interesting way is to remove
如果 Maven 更新快照不起作用并且您有 Spring Tooling,一种有趣的方法是删除
- Right-click on your project then Maven > Disable Maven Nature
- Right-click on your project then Spring Tools > Update Maven Dependencies
- After "BUILD SUCCESS", Right-click on your project then Configure > Convert Maven Project
- 右键单击您的项目,然后选择 Maven > Disable Maven Nature
- 右键单击您的项目,然后选择 Spring Tools > Update Maven Dependencies
- 在“BUILD SUCCESS”之后,右键单击您的项目,然后配置 > 转换 Maven 项目
Note: Maven update snapshot sometimes stops working if you use anything else i.e. eclipse:eclipse or Spring Tooling
注意:如果您使用其他任何东西,例如 eclipse:eclipse 或 Spring Tooling,Maven 更新快照有时会停止工作
回答by Gloria Rampur
On Intellij , right click Maven-> Reimport works fine
在 Intellij 上,右键单击 Maven-> Reimport 工作正常