一、錯誤信息
添加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>
重新編譯,錯誤解決。
