【问题标题】:Maven Enforcer plugin identifies Dependency Convergence issue within Camel-CXFMaven Enforcer 插件识别 Camel-CXF 中的依赖收敛问题
【发布时间】:2019-01-09 17:32:41
【问题描述】:

Maven 执行器插件正在识别我正在使用的第 3 方库的代码融合问题。如何在项目的其余部分仍然运行强制执行器插件的同时忽略这一点,或者我应该如何在不更改库版本的情况下解决问题?

我的项目使用了camel-cxf 2.13.2,结果它依赖于jaxb-impl 的两个独立传递版本; 2.1.13 和 2.2.6。执行器插件识别出这一点并导致构建失败。

这是我配置插件的方式:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.3.1</version>
        <configuration>
            <rules>
                <DependencyConvergence/>
            </rules>
        </configuration>
    </plugin>

当我运行mvn enforcer:enforce 时,我得到了

Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.sun.xml.bind:jaxb-impl:2.2.6 paths to dependency are:
+-com.myModule:module:18.0.0-SNAPSHOT
  +-org.apache.camel:camel-cxf:2.13.2
    +-org.apache.camel:camel-core:2.13.2
      +-com.sun.xml.bind:jaxb-impl:2.2.6
and
+-com.myModule:module:18.0.0-SNAPSHOT
  +-org.apache.camel:camel-cxf:2.13.2
    +-org.apache.cxf:cxf-rt-bindings-soap:2.7.11
      +-org.apache.cxf:cxf-rt-databinding-jaxb:2.7.11
        +-com.sun.xml.bind:jaxb-impl:2.1.13
and
+-com.myModule:module:18.0.0-SNAPSHOT
  +-org.apache.cxf:cxf-rt-management:2.7.11
    +-org.apache.cxf:cxf-rt-core:2.7.11
      +-com.sun.xml.bind:jaxb-impl:2.1.13

【问题讨论】:

    标签: maven apache-camel transitive-dependency maven-enforcer-plugin camel-cxf


    【解决方案1】:

    最后,我为特定的子依赖项添加了排除项,这些子依赖项引入了旧的、冲突的 jaxb-impl 版本。

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-core</artifactId>
        <version>${cxf.version}</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
            </exclusion>
        </exclusions>
        <scope>${framework.scope}</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-databinding-jaxb</artifactId>
        <version>${cxf.version}</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    

    这样我仍然可以在项目的其余部分上运行强制插件,如果发现新的收敛问题,则构建失败。

    【讨论】:

      【解决方案2】:

      我认为您不希望 maven 在出现收敛错误时使构建阶段失败。 在这种情况下,您需要在配置中设置 fail = false 标志,以便它只会注销收敛错误并继续下一阶段。

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M1</version>
        <executions>
          <execution>
            <id>dependency-convergence</id>
            <phase>install</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <DependencyConvergence />
              </rules>
              <fail>false</fail>
            </configuration>
          </execution>
          <executions>
            <plugin>
      

      注意:maven-enforcer-plugin 版本 1.3.1 非常旧。考虑将其升级到最新的 3.x.x。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-01-19
        • 1970-01-01
        • 2023-03-31
        • 1970-01-01
        • 1970-01-01
        • 2014-04-26
        • 2021-10-29
        相关资源
        最近更新 更多