@Bean
public SparkConf sparkConf() {
/*SparkConf sparkConf = new SparkConf()
.setAppName(appName)
.setSparkHome(sparkHome)
.setMaster(masterUri);*/
SparkConf sparkConf = new SparkConf();
sparkConf.set("spark.master", "yarn-client");
sparkConf.set("spark.local.ip","node1") ;
sparkConf.set("spark.driver.host","node1");
sparkConf.set("spark.sql.hive.metastore.jars", "builtin");
sparkConf.setAppName("Application name");
return sparkConf;
}
@Bean
public JavaSparkContext javaSparkContext() {
return new JavaSparkContext(sparkConf());
}
@Bean
public SparkSession sparkSession() {
/*return SparkSession
.builder()
// .sparkContext(javaSparkContext().sc())
.master("yarn")
.appName("Java Spark SQL basic example")
.enableHiveSupport()
.getOrCreate();*/
System.setProperty("HADOOP_USER_NAME", "root");
System.setProperty("SPARK_YARN_MODE", "yarn");
return SparkSession.builder().config(sparkConf()).enableHiveSupport().getOrCreate();
}
改成这样,还是那个错
|