scala - 带有 Spark 和 Cassandra 的 SBT 应用程序 - 类路径中缺少符号 'type <none>.package.DataFrame'

标签 scala apache-spark cassandra sbt datastax

我正在尝试创建简单的 Apache Spark 应用程序,该应用程序将使用 Datastax Cassandra 连接器连接到 Cassandra 并执行一些操作并出现错误
Symbol 'type <none>.package.DataFrame' is missing from the classpath.
我的 build.sbt :

name := "spark-app"
version := "1.0"
scalaVersion := "2.11.11"


libraryDependencies ++= Seq(
  "com.datastax.spark" %% "spark-cassandra-connector" % "2.0.0",
  "org.apache.spark" %% "spark-core" % "2.1.1" % "provided"
)

resolvers += "Spark Packages Repo" at "https://dl.bintray.com/spark-packages/maven"

我的简单应用:
package com.budgetbakers.be.dwh.spark
import com.datastax.spark.connector._
import org.apache.spark.{SparkConf, SparkContext}

object Distinct {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf(true)
      .set("spark.cassandra.connection.host", "127.0.0.1")

    val sc = new SparkContext(conf)
    println(sc.cassandraTable("ks", "users").select("gender").distinct().collect().mkString(","))
    sc.stop()
  }
}

当我尝试 package项目我得到以下编译错误:
[error] /.../Distinct.scala:18: Symbol 'type <none>.package.DataFrame' is missing from the classpath.
[error] This symbol is required by 'value com.datastax.spark.connector.package.dataFrame'.
[error] Make sure that type DataFrame is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'package.class' was compiled against an incompatible version of <none>.package.
[error]     println(sc.cassandraTable("ks", "users").select("gender").distinct().collect().mkString(","))
[error]             ^

我错过了什么吗?也许有一些依赖冲突?

我使用的应用程序版本:
  • Cassandra :3.1
  • Apache Spark :2.1.1
  • Spark Cassandra 连接器:2.0.0
  • 斯卡拉:2.11
  • sbt: 0.13.15
  • sbt 汇编插件:0.14.0
  • 最佳答案

    尝试添加 spark-sql依赖以及核心库。为了将来引用,有示例构建文件 here

    关于scala - 带有 Spark 和 Cassandra 的 SBT 应用程序 - 类路径中缺少符号 'type <none>.package.DataFrame',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44390534/

    相关文章:

    python - 使用结构化流(PySpark)运行链式查询

    cassandra - NoSQL 仲裁与虚拟分片的比较

    scala - 有没有办法展平不同类型的嵌套 monad?

    scala - 使用 sbt-release 指定自定义 git 标签

    java - Spark : Error While Writing DataFrame to CSV

    java - 如何将默认的 .ivy2 缓存目录更改为其他目录?

    cassandra - 何时在 Cassandra(和 CQL)表中使用 Blob,究竟什么是 Blob?

    mysql - 中国到 AWS 多主复制

    Scala:何时使用显式类型注释

    postgresql - Slick 使用 Postgres Sequence 而不是 serial