java 如何避免Maven中的禁止依赖错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32135670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to avoid banned dependency error in maven?
提问by luksmir
I cannot build my project due to following error:
由于以下错误,我无法构建我的项目:
[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.
I tried to use mvn install -Denforcer.skip=true
but it did not work as well
我尝试使用,mvn install -Denforcer.skip=true
但效果不佳
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
无法执行目标 org.apache.maven.plugins:maven-compiler-plugin
UPDATE:
更新:
I also tried to override the enforcer plugin as follows but still the error remains the same:
我还尝试按如下方式覆盖执行器插件,但错误仍然相同:
<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>
回答by Conor Roche
You can modify the configuration of the enforcer plugin. For example:
您可以修改执行器插件的配置。例如:
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>1.5</maxJdkVersion>
<excludes>
<exclude>org.mindrot:jbcrypt</exclude>
</excludes>
</enforceBytecodeVersion>
</rules>
<fail>true</fail>
</configuration>
You could increase the max JDK version.
您可以增加最大 JDK 版本。
You could add an exclude for the jars.
您可以为罐子添加排除项。
You could set fail to false.
您可以将失败设置为 false。