我按照文档示例Example: Estimator, Transformer, and Param
进行操作我收到了错误消息
15/09/23 11:46:51 INFO BlockManagerMaster:已注册的BlockManager 线程" main"中的例外情况java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror(Ljava /郎/类加载器;)Lscala /反映/ API / JavaUniverse $ JavaMirror; 在SimpleApp $ .main(hw.scala:75)
第75行是代码" sqlContext.createDataFrame()":
import java.util.Random
import org.apache.log4j.Logger
import org.apache.log4j.Level
import scala.io.Source
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.rdd._
import org.apache.spark.ml.classification.LogisticRegression
import org.apache.spark.ml.param.ParamMap
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import org.apache.spark.mllib.recommendation.{ALS, Rating, MatrixFactorizationModel}
import org.apache.spark.sql.Row
import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.functions._
object SimpleApp {
def main(args: Array[String]) {
val conf = new SparkConf().setAppName("Simple Application").setMaster("local[4]");
val sc = new SparkContext(conf)
val sqlContext = new SQLContext(sc)
val training = sqlContext.createDataFrame(Seq(
(1.0, Vectors.dense(0.0, 1.1, 0.1)),
(0.0, Vectors.dense(2.0, 1.0, -1.0)),
(0.0, Vectors.dense(2.0, 1.3, 1.0)),
(1.0, Vectors.dense(0.0, 1.2, -0.5))
)).toDF("label", "features")
}
}
我的sbt如下:
lazy val root = (project in file(".")).
settings(
name := "hello",
version := "1.0",
scalaVersion := "2.11.4"
)
libraryDependencies ++= {
Seq(
"org.apache.spark" %% "spark-core" % "1.4.1" % "provided",
"org.apache.spark" %% "spark-sql" % "1.4.1" % "provided",
"org.apache.spark" % "spark-hive_2.11" % "1.4.1",
"org.apache.spark" % "spark-mllib_2.11" % "1.4.1" % "provided",
"org.apache.spark" %% "spark-streaming" % "1.4.1" % "provided",
"org.apache.spark" %% "spark-streaming-kinesis-asl" % "1.4.1" % "provided"
)
}
我试图四处搜索并发现this post与我的问题非常相似,我试图改变我对火花版本的sbt设置(spark-mllib_2.11到2.10,spark-1.4.1到1.5.0),但它出现了更多的依赖冲突。
我的直觉是它有一些版本问题,但我自己无法弄清楚,有人可以帮忙吗?非常感谢。
答案 0 :(得分:2)
它现在正在为我工作,仅供记录,引用@MartinSenne答案。
我所做的如下:
@note: