IntelliJ IDEA + Maven iml文件中依赖项的需要是什么?
在Maven中,项目的依赖项在pom.xml文件中指定。在IntelliJ IDEA中,即使对于Maven项目,相同的信息也存储在iml文件中。在两个地方需要相同的信息需要什么?
In Maven, the dependencies of a project is specified in the pom.xml file. In IntelliJ IDEA, the same information is stored in an iml file even for Maven projects. What is the need for having the same infromation in two places?
导入Maven项目时,IDEA以格式表示其依赖项模型它可以在内部理解和使用。如果您通过Maven管理依赖项,则无需更改IntelliJ IDEA模块设置中的依赖项。
When importing Maven project IDEA represents its dependencies model in the format that it can understand and use internally. If you manage dependencies via Maven, you don't need to change the dependencies in the IntelliJ IDEA module setting.
这也可用于试验依赖项而不更改的pom.xml
。请注意,您所做的所有修改都将在下一次Maven导入时恢复。
This can be also used to experiment with dependencies without changing the pom.xml
. Note that all the modifications you make will be reverted on next Maven import.
换句话说,IDEA不直接理解Maven模型,它将其转换为自己的项目所有子系统使用的模型,内部项目信息需要存储在某处,因此 .iml
文件和 .idea
项目目录。这样,IDEA不需要在每次打开项目时分析pom文件并再次解析所有依赖项,只有在 pom.xml
更改时才会执行。
In other words, IDEA doesn't understand Maven model directly, it converts it to its own project model used by all the subsystems, and the internal project information needs to be stored somewhere, hence the .iml
files and .idea
project directory. This way IDEA doesn't need to analyze the pom file every time you open the project and resolve all the dependencies again, it's done only when the pom.xml
changes.
由于您可以在不使用Maven的情况下在IDEA中构建/运行/测试/部署/调试Maven项目,因此这些任务所需的信息以IDE可以理解的格式存储本身。它更快,更容易维护,我想比直接阅读Maven模型更容易实现。
As you can build/run/test/deploy/debug Maven projects in IDEA without using Maven at all, the information needed for these tasks is stored in the format that IDE can understand itself. It's faster, easier to maintain and I guess was easier to implement than reading Maven model directly.