运行ElasticSearch Spark示例代码时出错,我主要从[开始页面] [1]中获取。 错误是:
线程“main”中的异常java.lang.NoSuchMethodError: scala.Predef $ .ArrowAssoc(Ljava /郎/对象;)Ljava /郎/对象;在 org.elasticsearch.spark.rdd.EsSpark $ .saveToEs(EsSpark.scala:52)
这是我的sbt配置:
scalaVersion := "2.10.4"
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Conjars" at "http://conjars.org/repo"
resolvers += "cljars" at "https://clojars.org/repo/"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.0"
libraryDependencies += "org.apache.spark" % "spark-streaming_2.10" % "1.5.0"
libraryDependencies += "org.elasticsearch" % "elasticsearch" % "1.7.2"
libraryDependencies +="org.elasticsearch" % "elasticsearch-hadoop" % "2.1.1"
以下是失败的代码:(最后一行)
val upcomingTrip = Trip("OTP", "SFO")
val lastWeekTrip = Trip("MUC", "OTP")
val rdd = sc.makeRDD(Seq(upcomingTrip, lastWeekTrip))
EsSpark.saveToEs(rdd, "spark/docs")
使用以下命令运行:
bin/spark-submit --jars $(echo ../../elasticsearch-hadoop-2.1.1/dist/elasticsearch-spark-1.2_2.11-2.1.1.jar | tr ' ' ',') --class "Test" --master local[4] target/scala-2.10/simple-project_2.10-1.0.jar localhost 9999
我尝试将scala版本更改为2.11.4,并在编译时遇到问题。 有什么想法吗?