mysql-connector-java主要目的是Spark可以读取jdbc中的数据源;
spark-hive_2.11:通过Hive的元数据库进行连接的,Hive的元数据库在MySQL中存放的,因此需要引入MySQL,否则连接不上Hive。
<dependencies>
<!--引入SparkSQL-->
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.3.1</version>
</dependency>
<!--关联MySQL-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
<!--将Spark和Hive关联起来-->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.11</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>