java - 如何创建具有 Hive 支持的 SparkSession(失败并返回 "Hive classes are not found")?

标签 java apache-spark hive apache-spark-sql

我在尝试运行以下代码时遇到错误:

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class App {
  public static void main(String[] args) throws Exception {
    SparkSession
      .builder()
      .enableHiveSupport()
      .getOrCreate();        
  }
}

输出:

Exception in thread "main" java.lang.IllegalArgumentException: Unable to instantiate SparkSession with Hive support because Hive classes are not found.
    at org.apache.spark.sql.SparkSession$Builder.enableHiveSupport(SparkSession.scala:778)
    at com.training.hivetest.App.main(App.java:21)

如何解决?

最佳答案

将以下依赖项添加到您的 maven 项目。

<dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-hive_2.11</artifactId>
        <version>2.0.0</version>
</dependency>

关于java - 如何创建具有 Hive 支持的 SparkSession(失败并返回 "Hive classes are not found")?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39444493/

相关文章:

scala - 始终从 Spark 中的 s3 存储桶读取最新文件夹

apache-spark - 使用 Gradle 构建 Spark fat jar : shadow plugin yields corrupted JAR file

apache-spark - 在 Pyspark HiveContext 中,SQL OFFSET 相当于什么?

java - 我们可以使用 Linq 从 java 中的集合对象中获取值吗?

java - android BindService() 空指针异常

scala - Spark- “sbt package”- “value $ is not a member of StringContext”-缺少Scala插件吗?

mysql - 我不断收到此错误 Error in Hive while compiling statements : FAILED: ParseException line 2:16 mismatched input 'NOT' expecting ) near 'STRING'

java - 初学者 Java(获取要编译的类分配)

java - 在ListView中显示JsonArray

hadoop - hive 没有值(value)