gpt4 book ai didi

Maven 为父模块构建 jar

转载 作者:行者123 更新时间:2023-12-04 02:40:06 35 4
gpt4 key购买 nike

我在项目中有以下结构:

Project -
|- Parent // bunch of abstract classes which are used by children
|- child_A // depend on abstract classes from Parent
|- child_B // depend on abstract classes from Parent
|- child_C // depend on abstract classes from Parent

我也想为 parent 和 child build jar 。所以我最终会得到 parent.jar、child_*.jar。我如何在 maven 中执行此操作?

最佳答案

在 Maven 中,树 node 始终是类型为 pom 的项目(项目树定义)。类型为 jar 的模块始终是一棵树叶子(生成的产品)。树节点被命名为聚合器项目并且需要'pom'作为包装。

你的项目应该看起来像这样(你问的是 3 级)

+ Project parent (POM)
+ Abstract module (JAR) // bunch of abstract classes which are used by children
+ Implementation Modules (POM)
+ Module A (JAR) // depend on abstract classes from Abstract
+ Module B (JAR) // depend on abstract classes from Abstract
+ Module C (JAR) // depend on abstract classes from Abstract

抽象模块被配置为模块 A、B 和 C 中的依赖项。

关于Maven 为父模块构建 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20097464/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com