Maven编译错误记录:Some Enforcer rules have failed

一、错误信息

添加httpclient与httpcore依赖后编译Maven报错。

错误信息如下:

Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-banned-dependencies) on project manager: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-banned-dependencies) on project manager: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

二、错误定位

根据错误信息,定位到pom.xml的enforce-banned-dependencies。可能发生的错误:Java编译版本问题、被禁止依赖冲突问题。排除Java编译版本问题,查看新添加依赖包maven文件,dependency内容如下:

<dependency>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <scope>compile</scope>
</dependency>
commons-logging commons-logging compile

  由此,基本确定问题所在。

三、错误解决

在项目pom.xml文件新添加dependency元素节点中,添加子元素排除依赖冲突:

<exclusions>
  <exclusion>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
  </exclusion>
</exclusions>
commons-logging commons-logging

  重新编译,错误解决。

一、错误信息 添加httpclient与httpcore依赖后编译Maven报错。 错误信息如下: Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-banned-dependencies) on project manager: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. 二、错误定位 根据错误信息,定位到pom.xml的enforce-banned-dependencies。可能发生的错误:Java编译版本问题、被禁止依赖冲突问题。排除Java编译版本问题,查看新添加依赖包maven文件,dependency内容如下: commons-logging commons-logging compile   由此,基本确定问题所在。 三、错误解决 在项目pom.xml文件新添加dependency元素节点中,添加子元素排除依赖冲突: commons-logging commons-logging   重新编译,错误解决。
经验分享 程序员 微信小程序 职场和发展