首页 > 代码库 > A master URL must be set in your configuration问题解决方法

A master URL must be set in your configuration问题解决方法

 1 Using Spark‘s default log4j profile: org/apache/spark/log4j-defaults.properties
 2 16/10/21 18:13:00 INFO SparkContext: Running Spark version 2.0.0
 3 16/10/21 18:13:02 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
 4 16/10/21 18:13:04 ERROR SparkContext: Error initializing SparkContext.
 5 org.apache.spark.SparkException: A master URL must be set in your configuration
 6     at org.apache.spark.SparkContext.<init>(SparkContext.scala:371)
 7     at SummaryStatisticsExample$.main(SummaryStatisticsExample.scala:17)
 8     at SummaryStatisticsExample.main(SummaryStatisticsExample.scala)
 9     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
11     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12     at java.lang.reflect.Method.invoke(Method.java:606)
13     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
14 16/10/21 18:13:04 INFO SparkContext: Successfully stopped SparkContext
15 Exception in thread "main" org.apache.spark.SparkException: A master URL must be set in your configuration
16     at org.apache.spark.SparkContext.<init>(SparkContext.scala:371)
17     at SummaryStatisticsExample$.main(SummaryStatisticsExample.scala:17)
18     at SummaryStatisticsExample.main(SummaryStatisticsExample.scala)
19     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
21     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
22     at java.lang.reflect.Method.invoke(Method.java:606)
23     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
24 
25 
26 Process finished with exit code 1

在第5行位置提示:A master URL must be set in your configuration

解决方法:

Run->Edit Configurations->Configuration界面下,将VM-optionsz设置为“-Dspark.master=local”

A master URL must be set in your configuration问题解决方法