Maven“Module”vs“Project”(Eclipse,m2eclipse插件)

时间:2023-01-24 18:03:17

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类别中创建新项目时,这些是我的选择。

2 个解决方案

#1


215  

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中。该部分基本上对父项目说,“首先运行我对所有模块的每个命令”。因此,如果您在*项目上运行“mvn package”,它将首先针对其所有模块项目运行“mvn package”。

Hope that helps.

希望有所帮助。

#2


39  

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项目的子项目,通常称为父项目。

#1


215  

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中。该部分基本上对父项目说,“首先运行我对所有模块的每个命令”。因此,如果您在*项目上运行“mvn package”,它将首先针对其所有模块项目运行“mvn package”。

Hope that helps.

希望有所帮助。

#2


39  

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项目的子项目,通常称为父项目。