需求
在引用多个项目或者开源工具类,一般都比较容易存在重复的jar
依赖,但是不同版本之间可能存在不兼容的情况.人工排查起来稍微费力
查看依赖
mvn dependency:tree
enforcer实现
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<dependencyConvergence/>
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
执行命令
mvn validate