依赖冲突
打开IDEA右侧的maven栏,点开dependency总是会看到很多maven依赖是灰色提示。
-
omitted for duplicate
:表示重复依赖 -
omitted for conflict with x.x.x
:表示依赖已经冲突
mvn dependency:tree -Dverbose
可以列出项目的所有依赖以及传递性依赖。
另一种方法是
<!-- 强制检查maven依赖 在build中添加 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<dependencyConvergence/>
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
加入上面插件之后,编译的时候有冲突的话就会有错误提示。
Dependency convergence error for org.apache.spark:spark-core_2.11:2.1.0 paths to dependency are:
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-streaming_2.11:2.1.0
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-sql_2.11:2.1.0
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-sql_2.11:2.1.0
+-org.apache.spark:spark-catalyst_2.11:2.1.0
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-hive_2.11:2.1.0
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-mllib_2.11:2.1.0
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-mllib_2.11:2.1.0
+-org.apache.spark:spark-graphx_2.11:2.1.0
+-org.apache.spark:spark-core_2.11:2.1.0
and
+-com.fantasy:SparkSQLInAction:1.0-SNAPSHOT
+-org.apache.spark:spark-yarn_2.11:2.1.1
+-org.apache.spark:spark-core_2.11:2.1.1