错误:找不到Main()方法/运行spark代码

时间:2015-08-14 23:35:35

标签: eclipse scala apache-spark sbt main-method

我在eclipse IDE上使用spark-1.4.1,scala 2.10.5和我的代码。我遇到以下错误:

Error: Main() method not found 
Cannot export the JAR file as it does not recognize the main class 

如何开始编写火花代码?

import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf

object SimpleApp {
    def main(args: Array[String]) {
        val logFile = "YOUR_SPARK_HOME/README.md" // Should be some file on your system
        val conf = new SparkConf().setAppName("Simple Application")
        val sc = new SparkContext(conf)
        val logData = sc.textFile(logFile, 2).cache()
        val numAs = logData.filter(line => line.contains("a")).count()
        val numBs = logData.filter(line => line.contains("b")).count()
        println("Lines with a: %s, Lines with b: %s".format(numAs, numBs))
    }
}

0 个答案:

没有答案