gpt4 book ai didi

java - 线程 "main"java.lang.NoSuchMethodError : scala. Predef$.refArrayOps(

转载 作者:行者123 更新时间:2023-11-29 09:59:23 30 4
gpt4 key购买 nike

<分区>

我是 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" %

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com