如何强制intellij想法重读/更新pom文件中指定的所有依赖项?


当前回答

下面最左边的按钮(蓝色循环)也重新导入了所有的maven项目:

其他回答

要删除所有依赖项,只需删除本地maven repo: ~/。默认为M2文件夹。然后一个接一个地重建你的项目:

mvn clean
mvn package

打开“Maven Projects”选项卡/窗口,单击左上角的“Reimport All Maven Projects”,开始从它们的存储库中重新加载所有依赖项。状态栏显示该进程的相关信息。

是什么让你认为这是不正确的工作?也许任何依赖项都不能从存储库加载?

我遇到了一个问题,IntelliJ无法编译类,声称缺少项目之间的依赖关系。 按照这个问题的答案重新导入项目并不能解决问题。 我的解决方案是:

删除所有项目(项目标签/右键单击根文件夹/ maven /删除项目); 关闭编辑器; 在命令行上使用maven编译所有项目; 打开同一项目的编辑器; 再次将项目添加到maven (maven TAB /添加maven项目(绿色+)/选择根pom);

警告:在某些项目中,您可能必须增加maven导入的最大内存(maven选项卡/导入/导入器的VM选项中的maven设置)。

如果重新导入不起作用(即在pom更新后没有删除旧版本的依赖项),还有一个机会:

打开项目设置(CTRL+SHIFT+ALT+S) 在模块上,删除所有你想要重新导入的库(例如重复) IDEA会警告一些仍在使用,确认 应用并选择OK 然后重新导入所有的maven项目。

这在2022年仍然是一个问题。

The option Setting > Maven > Always update snapshots no longer works in IDEA 2022.2.2, probably because Maven 3 frowns upon it and IntelliJ seems to not have updated the IDE to make it function. A simple solution might be to be able to add maven -U clean install as a custom target to the Lifecycle list in the IDEA Maven tab, but if it is possible it is not clear how to do it (even after googling for days). A not as nice but viable solution would be to go into the Terminal tool of IDEA and typing maven -U clean install, but IDEA does not expose the maven command in its Terminal by default and again it is not clear how to configure it so that it would.