【问题标题】:Maven could not resolve dependencies from reactorMaven 无法解析反应堆的依赖关系
【发布时间】:2019-08-13 23:48:03
【问题描述】:

我在执行 `mvn clean package

时收到以下警告
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:fs-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:fs-api:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] o proj:fs-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:ep-api-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] o proj:pckg-models:jar:1.0.0-SNAPSHOT12345 (provided)
07:02:39 [WARNING] o proj:fs-api:jar:1.0.0-SNAPSHOT12345 (provided)
07:02:39 [WARNING] o proj:pckg-fs-models:jar:1.0.0-SNAPSHOT12345 (provided)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"
07:02:39 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
07:02:39 [WARNING] o proj:models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] o proj:ep-api-models:jar:1.0.0-SNAPSHOT12345 (compile)
07:02:39 [WARNING] Try running the build up to the lifecycle phase "package"

这些依赖项是反应器的一部分,但 maven 无法解决它。这可能是什么原因?

【问题讨论】:

  • 要么显示完整的 pom 文件,要么在 GitHub/Bitbucket 上创建一个示例项目或类似的项目来显示结构,否则无法猜测出什么问题。此外,您能准确说出这些消息的来源吗?
  • 您对这个问题有任何更新吗?我面临着完全相同的问题。
  • @ScanQR 我添加了关于如何解决此问题的答案

标签: maven maven-3


【解决方案1】:

问题是 maven 以某种方式尝试从远程存储库下载模块,但不应该这样做,因为它们尚未构建。就我而言,这是由调用聚合器目标的聚合器 Maven 插件引起的。这些聚合器目标需要有关项目依赖项的完整信息,因此 maven 会尝试下载它们。

我通过在我的项目中注释掉 所有 聚合器插件并重新构建它来解决此问题。如果 maven 不再下载它们,那么它们就是罪魁祸首。这些插件通常以 aggregate- 为目标。示例:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>license-maven-plugin</artifactId>
    <inherited>false</inherited>
    <version>1.16</version>
    <executions>
        <execution>
            <id>default-cli</id>
            <goals>
                <goal>aggregate-add-third-party</goal>
            </goals>
        </execution>
    </executions>
</plugin>

注意聚合添加第三方目标

相关文章:https://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-build/

有些插件就是我们所说的“聚合器”,这意味着它们实际上 确实想要有关完整多模块构建的所有信息 执行。这些插件在项目树上运行时会导致 Maven 在调用插件的 execute() 之前解决所有的孩子 方法。在这种模式下,插件只执行一次,但在 一次整棵树。 (作为旁注,你永远不想绑定一个 pom 中的聚合器目标,因为这会导致插件运行 嗯!递归构建,因为生命周期将进入每个孩子,并且 执行聚合器...这将导致 Maven 重新解析所有 儿童等)

一旦您确定了导致插件,您可以执行以下操作之一:

  1. 将它们移动到 Maven 配置文件中,以便它们仅在您使用配置文件时被激活
  2. 如果目标是报告,请将其移至 pom (see configuring reports) 上的报告部分。

【讨论】:

  • 我已经尝试过您的解决方案 1。但我收到与 OP 相同的警告。您是否有示例 POM.xml 在其中使聚合添加第三方工作没有警告?
猜你喜欢
  • 2020-08-16
  • 2020-09-09
  • 2022-01-23
  • 2020-09-17
  • 2015-06-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多