Scala-lesson3 IDEA下创建scala 的多模块项目

11 篇文章 0 订阅

 

本文主要讲解如何在 IDEA 下创建多模块的 scala 项目

 

主要分为几个部分

1.创建一个mavan 项目

2.创建新的模块

3.编写测试用例,测试

 

1.创建一个mavan 项目 : 

首先新建一个maven 项目 

 

 

 

 

2.创建新的模块 :

 

       如果要创建多模块的项目,代码是组织在各个模块的,我们把这个跟模块的源代码目录src删除。

 

      新创建一个模块

 

 

 

3.编写测试用例,测试

 

首先这个是 scala 的项目 ,我们更改该模块的 pom.xml 

按照 如下格式更改:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>scala-module</groupId>
    <artifactId>module-1</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <scala.version>2.11.6</scala.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.specs</groupId>
            <artifactId>specs</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                    <args>
                        <arg>-target:jvm-1.8</arg>
                    </args>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

 

 

 

 

新建一个 scala 源代码 目录:

 

 

 

最后我们编写个测试用例

代码:

 

/**
  * Created by szh on 2018/9/17.
  */
object TestCC {

  def main(args: Array[String]) {
    var zz = "fast fast fast"
    println(s"$zz, better better better")
  }

}

正确执行:

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值