2017-04-03 160 views
1

我是新來的Scala並獲得以下錯誤代碼INTELLJ任何一個可以請幫助解決它

 import org.apache.spark.{SparkContext, SparkConf} 
    object wordcount { 
    def main(args: Array[String]) 
     { 
     val conf = new SparkConf() 
     .setMaster("local[*]") 
     .setAppName("TestSpark") 
     .set("spark.executor.memory","2g") 

     val sc = new SparkContext(conf) 
     val a = sc.parallelize(Seq("This is the firstline", "This is the 
     second line", "This is the third line"))    
     val count = a.flatMap(x => x.split(" ")) 
     val counts = count.map(word => (word,1)).reduceByKey((x,y) => x+y) 
     counts.foreach(println) 

     } 

     } 

我得到以下錯誤:

 Exception in thread "main" java.lang.NoSuchMethodError:  
    scala.Predef$.refArrayOps([Ljava/lang/Object;) 
     Lscala/collection/mutable/ArrayOps; 
     at org.apache.spark.util.Utils$.getCallSite(Utils.scala:1342) 
    at org.apache.spark.SparkContext.<init>(SparkContext.scala:81) 
    at wordcount$.main(wordcount.scala:12) 
    at wordcount.main(wordcount.scala) 
    Using Spark's default log4j profile: org/apache/spark/log4j-  

下面是我的內置SBT

 name := "scalaprograms" 

     version := "1.0" 

     scalaVersion := "2.12.1" 

     libraryDependencies += "org.apache.spark" % "spark-core_2.11" % 

回答

8

如果要在使用Scala的2.11與spark-core_2.11合作。即用途:

scalaVersion := "2.11.8" 

AFAIK星火不使用Scala工作尚未2.12

+0

感謝這個工作 – Manoj4068

+0

馬諾 - 你能請註明這是一個公認的答案嗎? –

+0

@ Manoj4068你能接受這個答案嗎? –

相關問題