为什么Maven强制实施程序插件在Maven 3.6.1版中失败,但在3.6.2中通过?

如何解决为什么Maven强制实施程序插件在Maven 3.6.1版中失败,但在3.6.2中通过?

在我的一个项目中,我试图将DependencyConvergence规则与maven强制执行器插件一起使用。我观察到,如果我使用Maven 3.6.1,则强制执行程序将失败,并出现以下错误,但在maven 3.6.2中,该命令正常运行。

有人可以让我知道Maven 3.6.2中的哪些更改导致Debrajs-MacBook-Air:es-plugins debrajmanna$ java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11,mixed mode) 在3.6.2中通过但在其他低于3.6.2的Maven版本中失败吗?

我在GitHub上放置了一个示例项目,可以在其中复制该问题。

Debrajs-MacBook-Air:es-plugins debrajmanna$ ~/Downloads/apache-maven-3.6.1/bin/mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] es-plugins                                                         [pom]
[INFO] dedup                                                              [jar]
[INFO]
[INFO] -----------------------< org.example:es-plugins >-----------------------
[INFO] Building es-plugins 1.0-SNAPSHOT                                   [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ es-plugins ---
[INFO]
[INFO] -------------------------< org.example:dedup >--------------------------
[INFO] Building dedup 1.0-SNAPSHOT                                        [2/2]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ dedup ---
[WARNING]
Dependency convergence error for com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.apache.lucene:lucene-test-framework:8.5.1
      +-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.2

[WARNING]
Dependency convergence error for commons-logging:commons-logging:1.2 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpclient:4.5.10
        +-commons-logging:commons-logging:1.2
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpasyncclient:4.1.4
        +-commons-logging:commons-logging:1.2
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-commons-logging:commons-logging:1.1.3
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client-sniffer:7.7.1
      +-commons-logging:commons-logging:1.1.3
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-commons-logging:commons-logging:1.1.3

[WARNING]
Dependency convergence error for org.apache.httpcomponents:httpcore:4.4.12 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpclient:4.5.10
        +-org.apache.httpcomponents:httpcore:4.4.12
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpcore:4.4.12
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpasyncclient:4.1.4
        +-org.apache.httpcomponents:httpcore:4.4.10
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client-sniffer:7.7.1
      +-org.apache.httpcomponents:httpcore:4.4.12

[WARNING]
Dependency convergence error for org.apache.httpcomponents:httpclient:4.5.10 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpclient:4.5.10
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpasyncclient:4.1.4
        +-org.apache.httpcomponents:httpclient:4.5.6
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client-sniffer:7.7.1
      +-org.apache.httpcomponents:httpclient:4.5.10

[WARNING]
Dependency convergence error for org.apache.httpcomponents:httpcore-nio:4.4.10 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpasyncclient:4.1.4
        +-org.apache.httpcomponents:httpcore-nio:4.4.10
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.elasticsearch.client:elasticsearch-rest-client:7.7.1
      +-org.apache.httpcomponents:httpcore-nio:4.4.12

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability. See above detailed error message.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for es-plugins 1.0-SNAPSHOT:
[INFO]
[INFO] es-plugins ......................................... SUCCESS [  3.047 s]
[INFO] dedup .............................................. FAILURE [  0.856 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.131 s
[INFO] Finished at: 2020-08-29T11:41:55+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) on project dedup: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors,re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems,you can resume the build with the command
[ERROR]   mvn <goals> -rf :dedup

maven-enforcer-plugin-3.0.0-M2

Debrajs-MacBook-Air:es-plugins debrajmanna$ ~/Downloads/apache-maven-3.6.2/bin/mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] es-plugins                                                         [pom]
[INFO] dedup                                                              [jar]
[INFO]
[INFO] -----------------------< org.example:es-plugins >-----------------------
[INFO] Building es-plugins 1.0-SNAPSHOT                                   [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ es-plugins ---
[INFO]
[INFO] -------------------------< org.example:dedup >--------------------------
[INFO] Building dedup 1.0-SNAPSHOT                                        [2/2]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (javaversion-dependencyconvergence) @ dedup ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for es-plugins 1.0-SNAPSHOT:
[INFO]
[INFO] es-plugins ......................................... SUCCESS [  1.743 s]
[INFO] dedup .............................................. SUCCESS [  0.510 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.462 s
[INFO] Finished at: 2020-08-29T11:42:06+05:30
[INFO] ------------------------------------------------------------------------

在Maven 3.6.2中也可以正常工作。

<select class="form-control select2-blue select" style="width: 100%;" name="catid" id="catid">
                                    <option selected="selected">Tanlang</option>
                                    <option id="1">0</option>
                                    <option id="2">1</option>
                                    <option id="3">3</option>
                                    <option id="4">5</option>
                                    <option id="5">6</option>
                                    <option id="6">6</option>
                                    <option id="7">10</option>
                                    <option id="8">71</option>
                                    <option id="9">72</option>
                                    <option id="10">92</option>
                                </select>


 <select class="form-control select2-blue select" style="width: 100%;" name="cat_uz" id="cat_uz">
                                    <option selected="selected">Tanlang</option>
                                    <option id="v1">SMS to'plam</option>
                                    <optgroup label="Internet">
                                    <option id="v2">Oylik</option>
                                    <option id="v3">Kunlik</option>
                                    <option id="v4">OnNet</option>
                                    <option id="v5">Tungi DRIVE</option>
                                    <option id="v6">Tungi internet</option>
                                    </optgroup>
                                    <option id="v7">Daqiqa to'plami</option>
                                    <option id="v8">Asosiy xizmatlar</option>
                                    <option id="v9">Pullik xizmatlar</option>
                                    <option id="v10">Raqam</option>
                                </select>

<select class="form-control select2-blue select" style="width: 100%;" name="cat_ru" id="cat_ru" readonly>
                                    <option selected="selected">Tanlang</option>
                                    <option id="v1">SMS-пакеты</option>
                                    <option id="v2">Месячные</option>
                                    <option id="v3">Суточные</option>
                                    <option id="v4">OnNet</option>
                                    <option id="v5">Ночной DRIVE</option>
                                    <option id="v6">Ночные</option>
                                    <option id="v7">Пакеты минут</option>
                                    <option id="v8">Базовые  услуги</option>
                                    <option id="v9">Платные услуги</option>
                                    <option id="v10">Номер</option>
                                </select>

解决方法

它与MENFORCER-195MNG-6713有关,它们是Maven 3.6.2中修复的错误。

如果您使用的是3.6.2,请注意,因为此区域中有a further regression,直到3.6.3才被修复(不会影响您的示例)。


我如何找到这些票证

让我们分别查看每个失败。从第一个开始就很有意义:

Dependency convergence error for com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1 paths to dependency are:
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1
and
+-org.example:dedup:1.0-SNAPSHOT
  +-org.elasticsearch.test:framework:7.7.1
    +-org.apache.lucene:lucene-test-framework:8.5.1
      +-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.2

让我们看一下org.elasticsearch.test:framework's POM的相关部分:

<dependency>
    <groupId>com.carrotsearch.randomizedtesting</groupId>
    <artifactId>randomizedtesting-runner</artifactId>
    <version>2.7.1</version>
    <scope>compile</scope>
    <exclusions>
        <exclusion>
            <artifactId>*</artifactId>
            <groupId>*</groupId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-test-framework</artifactId>
    <version>8.5.1</version>
    <scope>compile</scope>
    <exclusions>
        <exclusion>
          <artifactId>*</artifactId>
          <groupId>*</groupId>
      </exclusion>
    </exclusions>
</dependency>

很明显,我们可以看到应该排除Lucene的所有传递依赖。但是,如果我们返回错误的这一部分,则Enforcer插件抱怨的2.7.2版本甚至不应该在依赖树中!

...
   +-org.apache.lucene:lucene-test-framework:8.5.1
        +-com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.2

当我为两个版本的Maven(3.6.1和3.6.2)打印Maven依赖关系树时,我看到的randomizedtesting-runner的唯一实例是2.7.1版本,因此有些混乱在这里。

我的直觉告诉我,通配符排除很可能是罪魁祸首,因此从那里搜索the release notes只是诸如“排除”或“通配符”之类的问题。原来我是对的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-