**
pom重复依赖问题处理:
**
1:问题背景:线上编译的时候出现下列错误:
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (enforce-banned-dependencies) on project XXXXX: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
根据描述找到具体未校验通过的地方:
Rule 0: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:
Found Banned Dependency: log4j:log4j:jar:1.2.16
Found Banned Dependency: junit:junit:jar:4.13.1
Use ‘mvn dependency:tree’ to locate the source of the banned dependencies.
2:根据上面的信息可以定位到是:log4j;junit两个包依赖问题;找到未编译通过的包:
然后用idea中的:maven helper插件;打开未编译通过的组件的pom文件,点击到Dependency Analyzer;然后用树形结构展示依赖关系,如下图所示:
在上面输入错误提示重复依赖的包,便可以定位到在哪里重复依赖了,如下图所示:
然后在对应的pom文件中排除该依赖就可以了,如下图所示: