与sbt + cassandra连接器依赖问题的火花流

时间:2017-02-24 19:11:42

标签: scala apache-spark sbt spark-streaming spark-cassandra-connector

民间,

我正在尝试将cassandra与火花流整合在一起。以下是sbt文件:

 scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "2.0.0" % "provided",
"org.apache.spark" %% "spark-streaming" % "2.0.0" % "provided",
"org.apache.spark" %% "spark-sql" % "1.6.1",
"com.datastax.spark" %% "spark-cassandra-connector" % "1.6.2",
"com.datastax.cassandra" % "cassandra-driver-core" % "3.0.0",
("org.apache.spark" %% "spark-streaming-kafka" % "1.6.0").
exclude("org.spark-project.spark", "unused")
)

我为cassandra集成添加了以下行(下面提到的错误行):

val lines = KafkaUtils.createDirectStream[
String, String, StringDecoder, StringDecoder](
ssc, kafkaParams, topics)

//Getting errors once I add below line in program 
lines.saveToCassandra("test", "test", SomeColumns("key", "value"))

lines.print()

一旦我添加上面的行,我在IDE中看到以下错误:

enter image description here

如果我尝试从命令提示符打包此项目,我会看到类似的错误:

enter image description here

FYR,我使用的是以下版本:

scala - 2.11

kafka - kafka_2.11-0.8.2.1

java - 8

cassandra - datastax-community-64bit_2.2.8

请帮助解决问题。

1 个答案:

答案 0 :(得分:0)

正如预期的那样,依赖性问题通过更新sbt文件解决,如下所示:

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "2.0.0" % "provided",
"org.apache.spark" %% "spark-streaming" % "2.0.0" % "provided",
"org.apache.spark" %% "spark-sql" % "2.0.0",
"com.datastax.spark" %% "spark-cassandra-connector" % "2.0.0-RC1",
"com.datastax.cassandra" % "cassandra-driver-core" % "3.0.0",
("org.apache.spark" %% "spark-streaming-kafka" % "1.6.0").
exclude("org.spark-project.spark", "unused")
)