gpt4 book ai didi

maven - Jenkins 构建多模块 Maven 项目失败

转载 作者:行者123 更新时间:2023-12-05 00:14:13 24 4
gpt4 key购买 nike

我有一个多模块 Maven 项目,其中有多个微服务作为模块,因此我的父级中列出了模块 pom.xml如下所示:

<modules>
<module>core</module>
<module>model-base</module>
<module>module1</module>
<module>module2</module>
...
<module>module5</module>
<module>module7</module>
<module>module6</module>
</modules>

这里 module7取决于 module5, 6所以我在我的 module7 中列出了如下依赖项 pom.xml :
<parent>
<artifactId>pojectA</artifactId>
<groupId>com.domain</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module7</artifactId>
<dependencies>
<dependency>
<groupId>com.domain</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.domain</groupId>
<artifactId>module5</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.domain</groupId>
<artifactId>module6</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

当我运行 mvn clean package在我的本地 module5, 6module7 之前调用正如预期的那样,但在 Jenkins 中,它正在尝试构建 module 5然后 module7使构建失败说:
[ERROR] Failed to execute goal on project module7: Could not resolve dependencies for project module7:jar:1.0-SNAPSHOT: Could not find artifact module6:jar:1.0-SNAPSHOT -> [Help 1]

我是否需要在我的 pom.xml 中运行任何其他作业或重新排序模块? ,从本地到 Jenkins 有什么不同?感谢您对此的任何帮助。

最佳答案

模块的顺序不相关。 Maven 识别出哪个项目依赖于其他项目,并相应地设置 react 器中的构建顺序。见 POM Reference, Aggregation (or Multi-Module) :

You do not need to consider the inter-module dependencies yourself when listing the modules, i.e. the ordering of the modules given by the POM is not important. Maven will topologically sort the modules such that dependencies are always build before dependent modules.

关于maven - Jenkins 构建多模块 Maven 项目失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38064925/

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