scala安装搭建和基础语法
scala的安装搭建
scala的下载地址
https://www.scala-lang.org/download/
scala在IDEA上的插件下载地址
https://plugins.jetbrains.com/plugin/1347-scala/versions
windows版本直接解压zip到指定目录下(不要中文路径),然后配置环境变量即可:
验证是否安装成功:
将下载下来的插件zip文件解压到IDEA的安装根目录下的plugins文件夹里面中,重启IDEA即可,也可以直接在IDEA上下载
导入scala插件:
选择project structure
选择“+”,添加scala的SDK
点击"Browse" ,并选择scala的安装目录:
安装完成后:
查看能否创建scala类:
所需的POM文件配置:
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
<!-- 如果想要用java -jar 来运行我们打包之后的jar包,则下面这个配置必须注释掉 -->
<!-- <scope>provided</scope>-->
</dependency>
</dependencies>
<build>
<plugins>
<!-- 限制jdk版本插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 编译scala需要用到的插件 -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile