Scala development environment and development tools

 

1. Windows development environment

1. Download and install scala-*.msi from the official website.

2. Configure environment variables in the same way as configuring java environment variables.

 

2. How Windows opens the scala interpreter

The scala interpreter, or REPL, can also be called the scala shell.

2.1. Enter scala directly

C:\Users\Administrator>scala
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131).
Type in expressions to have them evaluated.
Type :help for more information.

staircase>

2.2, shortcut keys

Use the shortcut key: win + R to enter scala directly in the window.

2.3. Enter sbt console

C:\Users\Administrator>sbt console
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from C:\Users\Administrator\.sbt\1.0\plugins
[info] Loading project definition from C:\Users\Administrator\project
[info] Set current project to administrator (in build file:/C:/Users/Administrator/)
[info] Updating ...
[info] Done updating.
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.4. Compiling...
[info]   Compilation completed in 8.976s.
[info] Starting scala interpreter...
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131).
Type in expressions for evaluation. Or try :help.

staircase>

 

3. IDEA's environment preparation

3.1 idea install scala plugin

Through offline installation, the problem of slow network speed during online installation can be avoided. My idea version: IntelliJ IDEA 2017.3.5 (Ultimate Edition)

1. Download IEDA's scala plugin from http://plugins.jetbrains.com/?idea_ce
2. Install Scala plugin: Configure -> Plugins -> Install plugin from disk -> Select Scala plugin -> OK -> Restart IDEA

 

4. Several ways for idea to create a new scala program

4.1 New scala project

4.1.2 Scala Engineering

File – new project – scala project – IDEA type

4.1.2 Maven Project

4.1.2.1 Reference documents

For the detailed installation process, please refer to this blog. You can also create a new ordinary maven project, and then directly copy the relevant content of the pom.xm of the github project template to the local.

1. Create a Maven Scala project in IntelliJ IDEA https://unmi.cc/intellij-idea-create-maven-scala-project/

2. scala Maven project template: https://github.com/datadevsh/scala-program-template (mainly look at the pom.xml file)

 

4.1.2.2 Steps of creating a new maven project

If the settings have been made according to the content of the blog, the new steps are as follows.

1. Select the maven project and select the configured scala maven project template

2. Set the maven configuration

3. Project name

4. Select Allow automatic import in the lower right corner

 

4.1.3 sbt

4.2 Create a new scala file

1. Right click on the folder and create a new one

2. Shortcut key to create a new Scala file: Ctrl + Alt + Insert

4.3 Three scala file types

1. scala class: ordinary scala file

2. scala Worksheet: You can write scala scripts. Can be written in a format similar to what is written in the scala shell. This file is in the idea and can be compiled in real time like the scala shell.

3、scala script:

4.4 Import scala project

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325293158&siteId=291194637