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.

二、錯誤定位

       根據錯誤信息,定位到pom.xml的enforce-banned-dependencies。可能發生的錯誤:Java編譯版本問題、被禁止依賴沖突問題。排除Java編譯版本問題,查看新添加依賴包maven文件,dependency內容如下:

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

  由此,基本確定問題所在。

三、錯誤解決

       在項目pom.xml文件新添加dependency元素節點中,添加子元素排除依賴沖突:

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

  重新編譯,錯誤解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM