Found Banned Dependency

Time:2020-10-28

background

When testing the environment to publish the service today, Jenkins compiled and reported an error

[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]

The Maven enforcer plugin has not been used before, because the latest modification only introduces the snapshot package of a service of other groups. It is thought that the package conflicts. Moreover, it is found that the two prohibited packages are introduced by snapshot package. Therefore, the first time is to exclude the package, so that the compilation can pass and the client can test normally. After that, slowly start to analyze the problem / / my.oschina.net/liuyon …
This article is very clear, involving two knowledge points. First, the Maven enforcer plugin plug-in, and second, the introduction of log package. Because these two knowledge points were not known before, they were at a loss when encountering problems. After understanding the problems, they were verified and found in the parent project of Maven project

<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>