共计 1545 个字符,预计需要花费 4 分钟才能阅读完成。
背景
今天测试环境发布服务的时候,Jenkins 编译报错
[INFO] — maven-enforcer-plugin:3.0.0-M3:enforce (enforce-rules) @ dealapi —
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:
Found Banned Dependency: ch.qos.logback:logback-classic:jar:1.2.3
Found Banned Dependency: ch.qos.logback:logback-core:jar:1.2.3
Use ‘mvn dependency:tree’ to locate the source of the banned dependencies.
[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 7.126 s
[INFO] Finished at: 2020-07-06T20:21:20+08:00
[INFO] ————————————————————————
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce (enforce-rules) on project cuxiaoapi: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
之前没用过 maven-enforcer-plugin,因为最近的修改只有引入了一个其他组的服务的 SNAPSHOT 包,以为是包冲突了,而且发现提示的这两个被禁止的包都是 SNAPSHOT 包引入的,因此第一时间先进行排除,使编译能通过,客户端可以正常测试,搞定以后,慢慢开始分析问题,https://my.oschina.net/liuyon…
这篇文章讲的很清楚了,涉及两个知识点,第一,maven-enforcer-plugin 插件,第二,日志包引入,由于这两个知识点之前都不知道,所以碰到问题就不知所措了,明白问题后,进行验证,发现在 maven 项目的 parent 项目中
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
<executions>
<execution>
<id>enforce-rules</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<banDuplicatePomDependencyVersions />
<bannedDependencies>
<excludes>
<exclude>ch.qos.logback:*:*</exclude>
<exclude>com.alibaba:fastjson:(,1.2.70)</exclude>