Maven“模块”与“项目” (Eclipse、m2eclipse 插件)
我是 Maven 的初学者,我从命令行的角度稍微使用过它,所以现在我尝试在 Eclipse 中使用它;我安装了 m2eclipse 插件来执行此操作。
但我从一开始就被难住了!显然我在某处遗漏了一些术语。我无法跟踪所有这些新的 Maven 术语...什么是 Maven 项目,什么是 Maven 模块?这些是我在 Eclipse 的 Maven 类别中创建新项目时的选项。
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们基本上是同一件事,但有一个区别。
创建模块时,必须指定一个父项目。
当您指定父项目时,它会向父项目
pom.xml
添加一个
部分。该部分基本上是对父项目说的:
首先运行我针对所有模块收到的每个命令
例如,如果您在顶级项目上运行
mvn package
,它将首先针对其所有模块项目运行mvn package
。提示:
确保所有模块具有高内聚性并且相互关联,否则如果不应用SRP(单一职责原则),你将拥有一个巨大而混乱的项目
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 projectspom.xml
.That section basically says to the parent project:
run every command I get against all of my modules first
So for example, if you run,
mvn package
on the top-level project, it will runmvn package
against all its module projects first.Hint:
Make sure all modules have high cohesion and related to each other, otherwise you will have a huge messy project without applying SRP (Single Responsibility Principle)
找到了!我的搜索返回了大量关于创建“多模块项目”的点击,但是一旦我将“-multi”添加到我的查询中,答案就在第一页上。
根据创建和导入项目:
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.
According to Creating and Importing Projects: