Mac spark环境搭建(idea版本)

环境配置

Mac OS :13.3.1 (22E261)

开发工具:IntelliJ IDEA

maven版本:3.8.1

安装步骤:

S0:创建maven空项目:

Snipaste_2023-04-26_10-08-13

(* 本项目为云计算课程大作业的前置要求,故项目名称为Cloud)

Snipaste_2023-04-26_10-08-50

S1.安装Scala插件

文件(File)-- 设置(Settings)-- 插件(Plugins)

Snipaste_2023-04-26_10-10-23

S2.Maven 引包:

打开pom.xml文件

在如图位置编辑代码,插入

    <!-- 基础配置 -->
    <build>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Snipaste_2023-04-26_10-14-53

编辑完成后需要重新加载项目

Snipaste_2023-04-26_10-15-20

S3.添加Scala库

项目设置–库(Lib)-- “+” --下载

Snipaste_2023-04-26_10-37-39

Snipaste_2023-04-26_10-38-01

S4.创建Scala类

Snipaste_2023-04-26_10-38-28

选择Object类型

Snipaste_2023-04-26_10-39-44

编辑以下代码:

  def main(args: Array[String]): Unit = {
    print("hello world!")
  }

Snipaste_2023-04-26_10-40-27

运行程序:

Snipaste_2023-04-26_10-41-08

到此,环境搭建成功。

参考:

https://blog.csdn.net/feng8403000/article/details/122693015

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐