Exception in thread “main“ java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V

created at 05-30-2022 views: 58

I am getting the following error when running spark code in idea

error:

Exception in thread "main" java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
    at org.apache.spark.SparkConf$DeprecatedConfig.<init>(SparkConf.scala:809)
    at org.apache.spark.SparkConf$.<init>(SparkConf.scala:642)
    at org.apache.spark.SparkConf$.<clinit>(SparkConf.scala)
    at org.apache.spark.SparkConf.set(SparkConf.scala:94)
    at org.apache.spark.SparkConf.set(SparkConf.scala:83)
    at org.apache.spark.SparkConf.setAppName(SparkConf.scala:120)
    at cn.itcast.spark.wordcount$.main(wordcount.scala:11)
    at cn.itcast.spark.wordcount.main(wordcount.scala

reason

after some check I found:

  • The corresponding version of spark is 2.12
  • scala version is 2.11

solution

The problem is solved after changing the scala version to 2.12

created at:05-30-2022
edited at: 05-30-2022: