1. 程式人生 > >Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.d

Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.d

Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.driver.allowMultipleContexts = true. The currently running SparkContext was created at:XXX

解決:
該報錯是因為建立了多個sparkContext, 一般是因為在建立StreamingContext的時候使用了SparkContext而非SparkConf

val conf = new SparkConf
().setAppName("SparkStreamingAndKafka").setMaster("local[2]") val sc = new SparkContext(conf) val ssc = new StreamingContext(conf, Seconds(5))

將val sc = new SparkContext(conf)註釋掉