Maven无法解决来自反应堆的依赖关系

时间:2019-03-22 23:15:18

标签: maven maven-3

我执行“ 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无法解决它。这可能是什么原因?

1 个答案:

答案 0 :(得分: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中的聚合器目标,因为这将导致插件运行 n!递归构建,因为生命周期将进入每个孩子并 执行聚合器...这将导致Maven重新解析所有 儿童等)

一旦确定了引起问题的插件,您可以执行以下操作之一:

  1. 将它们移动到Maven个人资料上,以便仅在使用个人资料时激活它们
  2. 如果目标是作为报告,请将其移至pom(see configuring reports)上的报告部分。