我在Mac上的IntelliJ IDEA中有以下简单代码:
2016-06-09
2016-06-10
在我的运行配置中,我添加了以下程序参数:
2016-06-09
当我运行此代码时,出现以下错误:
2016-06-10
我该怎么做才能克服这个错误?
答案 0 :(得分:2)
在任何一步之后让智能准备就绪,因为从某个时候拉出maven会很慢
Preferences > Plugins > Scala
File > New > Project
,在左侧窗格中选择Scala
,在右侧窗格中选择SBT
Open Module Settings
> Libraries
+
模块图标> Maven
> org.apache.spark:spark-core_2.11:1.6.1
> Enter
project name
scala file
中的新src/main/scala
例如。 Test.scala import org.apache.spark.{SparkContext,SparkConf}
object Test {
def main(args: Array[String]){
val conf = new SparkConf().setAppName("DevDemo").setMaster("local")
val sc = new SparkContext(conf)
val inputFile = sc.textFile("/var/log/fsck_hfs.log").cache()
// Creates a DataFrame having a single column named "line"
val errAs = inputFile.filter(line => line.contains("ERROR"))
println("Error count : %s".format(errAs.count()))
}
}
Run Menu
> Run
结果:<<<<剪断
16/06/13 14:39:19 INFO DAGScheduler: ResultStage 0 (count at Test.scala:14) finished in 1.258 s
16/06/13 14:39:19 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
16/06/13 14:39:19 INFO DAGScheduler: Job 0 finished: count at Test.scala:14, took 1.829030 s
Error count : 18
答案 1 :(得分:0)
您应该尝试以下行
val sc =新的SparkContext(conf = conf)