spark 异常解决:A master URL must be set in your configuration
程序员文章站
2022-07-12 14:16:09
...
为了省去每次都创建spark对象,写了一个基础类SparkSessionBase,没想到集群抛出异常:A master URL must be set in your configuration。原因就在于spark对象在main函数之外创建…
class SparkSessionBase {
protected val spark:SparkSession =SparkSession.builder().enableHiveSupport().getOrCreate();
}
object ImportHiveData2Kafka extends SparkSessionBase {
def main(args: Array[String]): Unit = {
val topic = args(0)
val dataType = args(1)
val dataSourceType = args(2)
var infos: Dataset[String] = null
dataSourceType match {
case "parquet" => {infos = spark.read.load(args(3)).toJSON}
case "hive" => {infos = spark.sql("select * from " + args(3) + " where dt='" + args(4) +"'").toJSON}
case _ => null
}
infos.foreachPartition(info => importToKafka(topic, dataType, info.toList))
spark.close()
}
}
上一篇: 解决A master URL must be set in your configuration错误
下一篇: IDEA开发SparkSQL报错:org.apache.spark.SparkException: A master URL must be set in your configuration
推荐阅读
-
Spark异常:A master URL must be set in your configuration处理记录
-
IDEA开发SparkSQL报错:org.apache.spark.SparkException: A master URL must be set in your configuration
-
IDEA使用SparkSession读取Json文件报错 A master URL must be set in your configuration
-
运行Spark程序时出现 Exception in thread “main“ org.apache.spark.SparkException: A master URL must be set
-
Spark程序报错排查:A master URL must be set in your configuration
-
异常解决:A master URL must be set in your configuration
-
org.apache.spark.SparkException: A master URL must be set in your configuration
-
解决A master URL must be set in your configuration错误
-
spark 异常解决:A master URL must be set in your configuration
-
Spark异常:A master URL must be set in your configuration处理记录