Maven Helper可以帮助程序员快速定位依赖冲突并且解决它们
例如:
pom.xml
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>${hive.version}</version>
</dependency>
这里的2个依赖存在冲突,直接打包运行会有冲突导致不可运行,使用 Dependency Analyzer查看依赖详情
点击 [Jump to Left Tree],查看依赖树:
依赖树:
我这里想要使用的hive-exec里包含了 “calcite-avatica”,这个依赖里又包含了红色部分的依赖"janino",而"janino"被"flink-table-planner-blink"引用,因此冲突了。
如何解决:
接下来,只需从hive-exec里排除"calcite-avatica"就可以了,点击"exclude"
查看pom.xml,"calcite-avatica"已经从hive-exec排除掉,重新打包即可。
<exclusion>
<artifactId>calcite-avatica</artifactId>
<groupId>org.apache.calcite</groupId>
</exclusion>