为了账号安全,请及时绑定邮箱和手机立即绑定

Maven:如何处理包含模块的模块?

Maven:如何处理包含模块的模块?

炎炎设计 2023-04-26 16:21:07
以前我曾处理过由两个层次结构组成的多模块 Maven 项目。父 POM 之后是它们自己的目录和 POM 中的模块。但是现在我接管了一个包含父项的项目,然后是再次包含模块的模块。这一切都是根据 Maven 指南还是我在处理定制的东西?以及如何解释这些子模块?知道可以指点我的指南吗?我可以成功运行所有 Maven 生命周期。尽管我不确定是否以及如何重构应用程序并开始插入我自己的代码。这是我的项目结构树,只剩下几个模块:top-parent|   pom.xml (modules: applications, checks, core, test)|           +---applications |   |   pom.xml (parent: top-parent) (modules: batch, surefire, web)    |       <parent>|         <artifactId>applications</artifactId>|         <groupId>com.a.b.codechecker</groupId>|         <version>1.0</version>|       </parent>|       <artifactId>batch</artifactId>  |  |   |                       |   \---web|       |   pom.xml|           <parent>|             <groupId>com.a.b.codechecker</groupId>|             <artifactId>applications</artifactId>             |             <version>1.0</version>|           </parent>|           <artifactId>web</artifactId>|                               +---checks|   |   pom.xml (parent: top parent) (modules: aggregator, blacklist-check)|       <parent>|         <groupId>com.a.b.codechecker</groupId>|         <artifactId>parent</artifactId>|         <version>1.0</version>|       </parent>|       <groupId>com.a.b.codechecker.checks</groupId>|       <artifactId>checks</artifactId>|   ||   +---aggregator|       |   pom.xml            <parent>              <artifactId>checks</artifactId>              <groupId>com.a.b.codechecker.checks</groupId>              <version>1.0</version>            </parent>            <artifactId>aggregator</artifactId> 
查看完整描述

1 回答

?
皈依舞

TA贡献1851条经验 获得超3个赞

我在下面提供了一些大纲。

根据问题, 这都是根据 Maven 指南还是我正在处理定制的东西?

是的,你可以有 Parent, Child, Grand child 类型的模块结构。Parent and Child 类型的 maven 多模块层次结构很简单,但在某些情况下,开发人员设计为在一个模块内有多个子模块。如果您的大型项目有 n 个模块和 m 个子模块,那么对于不同级别的开发人员来说,它会变得很复杂。

根据这个问题, 我该如何解释这些子模块?知道可以指点我的指南吗? 为简单起见,如何管理取决于开发团队。我会建议,如果你有很多子模块,你可以创建/维护另一个独立的项目,你可以在需要的地方将依赖项添加到主项目中。它将为您提供该项目的粒度和单独的团队工作,而无需考虑主要项目。

对于大型项目,始终建议维护独立的项目,您可以在其他项目中添加依赖。为此,您可以使用 Nexus 或 Artifactory 进行工件管理。


查看完整回答
反对 回复 2023-04-26
  • 1 回答
  • 0 关注
  • 63 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信