idea添加scala环境_IDEA 下 meavn 开发 scala 程序

852a297566dd0bc09cff76cfbba3bd08.png

IDEA 下 meavn 开发 scala 程序,一般有两种方式:

  • 第一种:安装好 Scala, 通过 IDEA Scala 插件进行开发
  • 第二种:使用 maven 插件包进行开发

一、通过 IDEA Scala 插件开发

1. 安装 Scala 插件

a8f4145fba3af6b1cc994e85fe61d4c6.png

2. 创建 Maven 工程,Add Frameworks Support(Scala)

2.1 创建项目名称为scala-plugin的 maven 项目

96be47886f0302ea5d7b9f86dbedd5ec.png

2.2 Add Frameworks Support

右键点击工程目录,选择Add Frameworks Support

387fc356e57e28ab086a64e480f5de30.png

选择 Scala,点击确定

ce6d623350734d2563bdb169fcad48e0.png

这样,就可以右键新建 Scala 文件了

60d7e5ab44540e9b5c3e4d4ab710bd44.png

1.3 添加 scala 源目录,进行开发

src/main下新建scala目录,右键 --> Make Directory as --> Source Root

4434add7c374e55a075a7921bb421c91.png

在 scala 目录下新建Test.scala,运行进行验证

ade8b6d711163f6b0f60d2195231bd72.png

二、通过 maven plugin 插件进行开发

1. 添加 scala 依赖

<properties>
    <maven.compiler.source.version>1.8</maven.compiler.source.version>
    <maven.compiler.target.version>1.8</maven.compiler.target.version>
    <encoding>UTF-8</encoding>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <scala.version>2.11.8</scala.version>
</properties>


<dependencies>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
    </dependency>
</dependencies>

2. 添加 scala-maven-plugin 插件

<build>
    <plugins>
        <!-- This plugin compiles Scala files -->
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>scala-compile-first</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>scala-test-compile</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <scalaVersion>${scala.version}</scalaVersion>
            </configuration>
        </plugin>
    </plugins>
</build>

3. 添加 scala 源目录进行开发

同 IDEA Scala 插件开发的 1.3

如果项目需要多人进行合作开发的话,建议使用 maven plugin 的方式进行开发
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值