如何避免maven中被禁止的依赖错误?

时间:2015-08-21 08:25:50

标签: java maven

由于以下错误,我无法构建我的项目:

[WARNING] Rule 6: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
Found Banned Dependency: de.lmu.ifi.dbs.utilities:common-extension-lib:jar:2.4.0
Found Banned Dependency: de.lmu.ifi.dbs.jfeaturelib:JFeatureLib:jar:1.6.1
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-rules) on project : 
Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

我尝试使用mvn install -Denforcer.skip=true,但效果不佳

  

无法执行目标org.apache.maven.plugins:maven-compiler-plugin

更新:

我还尝试按如下方式覆盖enforcer插件,但错误仍然相同:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <executions>
        <execution>
            <id>enforce-banned-dependencies</id>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <rules>
                    <bannedDependencies>
                        <includes>
                            <include>de.lmu.ifi.dbs.utilities:common-extension-lib</include>
                            <include>de.lmu.ifi.dbs.jfeaturelib:JFeatureLib</include>
                        </includes>
                    </bannedDependencies>
                </rules>
                <enforceBytecodeVersion>
                    <maxJdkVersion>1.6</maxJdkVersion>
                    <excludes>
                        <exclude>de.lmu.ifi.dbs.jfeaturelib:JFeatureLib</exclude>
                        <exclude>de.lmu.ifi.dbs.utilities:common-extension-lib</exclude>
                    </excludes>
                </enforceBytecodeVersion>

            </configuration>
        </execution>
    </executions>
</plugin>

1 个答案:

答案 0 :(得分:1)

您可以修改enforcer插件的配置。 例如:

<configuration>
   <rules>
      <enforceBytecodeVersion>
         <maxJdkVersion>1.5</maxJdkVersion>
            <excludes>
               <exclude>org.mindrot:jbcrypt</exclude>
            </excludes>
      </enforceBytecodeVersion>
   </rules>
   <fail>true</fail>
</configuration>

您可以增加最大JDK版本。

您可以为罐子添加排除。

您可以将fail设置为false。