寒假学习 7

  1. sbt 对 Scala 应用程序进行编译打包

/* SimpleApp.scala */

import org.apache.spark.SparkContext

import org.apache.spark.SparkContext._

import org.apache.spark.SparkConf

  • object SimpleApp {

def main(args: Array[String]){

        val logFile = " hdfs://localhost:9000/user/hadoop/test.txt"

              val conf = new SparkConf().setAppName("Simple Application")

              val sc = new SparkContext(conf)

        val logData = sc.textFile(logFile, 2)

        val num = logData.count()

        printf("The num of this file is %d", num)

 }

}

  1. 通过如下代码将整个应用程序打包成 JAR:
  2.  

posted @ 2024-02-25 15:29  搜一码赛  阅读(4)  评论(0编辑  收藏  举报