java - 父 pom 中的 Maven 子模块作为依赖项
问题描述
我正在尝试创建一个包含多个模块的 Maven spring-boot 项目。我创建了一个包装类型为pom的父模块和许多包装类型为jar的子模块。
所以我父母的pom.xml看起来像:
<groupId>Creator</groupId>
<artifactId>DPAI</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>starter</module>
<module>DatabaseApi</module>
...
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
子模块之一: starter 仅包含用 @SpringBootApplicatoion 注释的起始类,并且在其 pom.xml 中有一个包含其他子工件的部分,例如:
<parent>
<artifactId>DPAI</artifactId>
<groupId>Creator</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>starter</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>Creator</groupId>
<artifactId>DatabaseApi</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
</dependencies>
因此,我正在尝试进行一些重构并将 Main.class 和所有依赖项移动到我父母的 pom 中,但它不会因为我的依赖项引用自身的消息而出现错误。
在我看来,问题在于我的父 pom 包含带有它自己的子模块的部分。该子模块的父级是同一个 pom,我尝试在其中添加描述的依赖项
解决方案
parent.pom 不能包含任何 java 代码,只能包含 Maven 细节,例如参见:https ://howtodoinjava.com/maven/maven-parent-child-pom-example/#parent-content
也许告诉我们,你想要实现什么。
推荐阅读
- matlab-figure - 如何在 MatLab 中生成 PWM
- c# - 用于捕获其他字符不跟随的数字模式的正则表达式
- hyperledger-fabric - 我想构建一个 Hyperledger Fabric 网络,在多个组织的多个主机上运行
- java - 如何将临时授予的 ContentProvider 权限传递给 Service?
- c# - 登录网站并使用 Html Agility Pack 设置用户代理
- swift - 如何使用枚举创建计算函数?
- docker - Dockerfile 的第一行 - 什么操作系统?
- authorization - 为动态角色和属性建模 XACML 策略
- kubernetes - Traefik 入口不适用于集群 IP
- ionic-framework - 如何将我的 Ionic 4 应用程序升级到最新的 Ionic 版本?