java 如何在 Intellij 13.1.4 的 maven 多模块项目中重建/制作 .iml 文件

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

How do I rebuild/make .iml files in maven multi-module project in Intellij 13.1.4

javamavenintellij-ideapom.xml

提问by Carlos Bribiescas

I'm working in a multi-module maven project in Intellij. There was a snapshot update in another module which required an update in a few POMs. Normally I will click the "Re-import all maven projects" from the maven plugins tool then do a full build.

我正在 Intellij 中的一个多模块 maven 项目中工作。另一个模块中有一个快照更新,需要在几个 POM 中进行更新。通常,我会从 maven 插件工具中单击“重新导入所有 maven 项目”,然后进行完整构建。

However, this time the .iml files associated with the changed POMs weren't being updated. It wasn't until I did "Build->Rebuild Project" that the .iml files were updated. Does anyone know how to update .iml files as part of a build configuration?

但是,这次与更改的 POM 关联的 .iml 文件没有更新。直到我执行“Build-> Rebuild Project”,.iml 文件才被更新。有谁知道如何将 .iml 文件更新为构建配置的一部分?

Note: Before rebuilding the project, I know mvn at least picked up on the change because my local .m2 repo had the latest snapshot.

注意:在重建项目之前,我知道 mvn 至少接受了更改,因为我的本地 .m2 存储库有最新的快照。

EDIT #1: So, this is also true if I add a maven runtime dependency in a module. It won't pick up the change unless I do rebuild project.

编辑 #1:因此,如果我在模块中添加 Maven 运行时依赖项,这也是正确的。除非我重建项目,否则它不会改变。

回答by ilooner

I've experienced similar issues with newer versions of IntelliJ (2018.2.7) where my .iml is out of date. It happens inconsistently, so I'm not sure what the root cause is, but the following work around allows me to avoid doing a full rebuild:

我在较新版本的 IntelliJ (2018.2.7) 中遇到了类似的问题,其中我的 .iml 已过时。它发生不一致,所以我不确定根本原因是什么,但以下解决方法使我可以避免进行完全重建:

  1. Delete the .iml file for the project
  2. Reimport the pom.xml for the project
  3. IntelliJ will automagically regenerate an updated .iml file.
  1. 删除项目的 .iml 文件
  2. 重新导入项目的 pom.xml
  3. IntelliJ 将自动重新生成更新的 .iml 文件。