IDEA SPARK SCALA 搭建简单的helloworld

2017-05-04  本文已影响0人  牛马风情

新建maven工程:

Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png

配置工程属性、工程目录、scala库

如下图,左边为项目结构,src 目录下为编写的代码,main为程序代码,test为测试代码。pom.xml文件为maven的打包关联依赖及编译文件

Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png Paste_Image.png
 <dependencies>
        <!-- https://mvnrepository.com/artifact/org.scala-lang/scala-library -->
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.8</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core_2.11 -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>2.1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-mllib_2.11 -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-mllib_2.11</artifactId>
            <version>2.1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql_2.11 -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.11</artifactId>
            <version>2.1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.spark/spark-hive_2.11 -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-hive_2.11</artifactId>
            <version>2.1.0</version>
        </dependency>
    </dependencies>
Paste_Image.png Paste_Image.png

编写helloworld

Paste_Image.png Paste_Image.png
object HelloWord {
  def main(args: Array[String]) {
    println("Hello World!");
  }
}

-右键点击 HelloWord 程序代码,点击 run HelloWord :

Paste_Image.png Paste_Image.png
上一篇下一篇

猜你喜欢

热点阅读