Maven“模块”与“项目”(Eclipse,m2eclipse 插件)

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

Maven "Module" vs "Project" (Eclipse, m2eclipse plugin)

eclipsemavenm2eclipse

提问by Ricket

I'm a beginner at Maven and I've played with it from a command line point of view a little, so now I was trying to use it in Eclipse; I installed the m2eclipse plugin to do so.

我是 Maven 的初学者,我从命令行的角度玩过它,所以现在我试图在 Eclipse 中使用它;我安装了 m2eclipse 插件来做到这一点。

But I'm stumped from the very beginning! Apparently I've missed a bit of terminology somewhere along the line. I can't keep track of all these new Maven terms... What is a Maven Project, and what is a Maven Module?These are my options when creating a new project in the Maven category in Eclipse.

但我从一开始就被难住了!显然,我错过了沿线某处的一些术语。我无法跟踪所有这些新的 Maven 术语……什么是 Maven 项目,什么是 Maven 模块?这些是我在 Eclipse 的 Maven 类别中创建新项目时的选项。

回答by Steve

They are basically the same thing, but with one difference. When you create a module, you must specify a parent project. When you specify the parent project, it adds a <modules> section to the parent projects pom.xml. That section basically says to the parent project, "run every command I get against all of my modules first". So if you run, "mvn package" on the top level project, it will run "mvn package" against all it's module projects first.

它们基本上是一回事,但有一个区别。创建模块时,必须指定父项目。当您指定父项目时,它会向父项目 pom.xml 添加一个 <modules> 部分。该部分基本上对父项目说,“首先针对我的所有模块运行我收到的每个命令”。因此,如果您在顶级项目上运行“mvn package”,它将首先针对它的所有模块项目运行“mvn package”。

Hope that helps.

希望有帮助。

回答by Ricket

Found it! My searches were returning tons of hits for creating a "multi-module project", but once I added "-multi" to my query, the answer was on the first page.

找到了!我的搜索返回了创建“多模块项目”的大量点击,但是一旦我将“-multi”添加到我的查询中,答案就在第一页上。

According to Creating and Importing Projects:

根据创建和导入项目

m2eclipse provides the ability to create a Maven module. Creating a Maven module is almost identical to creating a Maven project as it also creates a new Maven project using a Maven archetype. However, a Maven module is a subproject of another Maven project typically known as a parent project.

m2eclipse 提供了创建 Maven 模块的能力。创建 Maven 模块几乎与创建 Maven 项目相同,因为它还使用 Maven 原型创建新的 Maven 项目。但是,Maven 模块是另一个 Maven 项目的子项目,通常称为父项目。