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


当前回答

还有一个有用的设置告诉IntelliJ检查依赖项的新版本,即使版本号没有改变。我们有一个本地maven存储库和一个快照项目,它更新了几次,但版本号保持不变。问题是IntelliJ/Maven没有更新这个项目,因为版本号是固定的。

要启用检查变更的依赖关系,尽管版本号没有改变,请进入“Maven项目”选项卡,选择“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.

还有一个有用的设置告诉IntelliJ检查依赖项的新版本,即使版本号没有改变。我们有一个本地maven存储库和一个快照项目,它更新了几次,但版本号保持不变。问题是IntelliJ/Maven没有更新这个项目,因为版本号是固定的。

要启用检查变更的依赖关系,尽管版本号没有改变,请进入“Maven项目”选项卡,选择“Maven设置”,并在那里激活“始终更新快照”。

有两种方法可以做到。

1号路

进入文件>设置>构建,执行,部署>构建工具| Maven

选择“始终更新快照”

Apply和OK

2号路 mvn -U clean install

如果您正在为任何依赖项使用版本范围,请确保IntelliJ正在使用Maven 3导入项目。您可以在以下路径中找到此设置:设置> Maven >导入>使用Maven3导入项目。否则可能会导致快照版本导入不正确。

对于IntelliJ IDEA 14.0

项目>[您的项目名称]>右键单击> Maven >重新导入