IntelliJ IDEA 安裝 Scala plugins
這裡僅是紀錄學習與安裝過程,
當作下次環境安裝時的提示。
隨版本異動關步驟可能或有所變動, 必要時在上官網找找吧。畢竟 Scala2 到 Scala3 似乎有大異動,相關 Plugins 也跟著調整
IntelliJ IDEA 安裝 Scala plugins
- SDK 安裝
- Scala SDK 安裝: https://www.scala-lang.org/download/
- JDK 安裝
- IntelliJ Community Edition 安裝
- Scala Plugins 安裝

- Project Setting
Create Scala Project(IntelliJ Community Edition)
- File 🢂 New 🢂 Project




object Hello extends App {
println("Hello, World!")
}

Scala Worksheet 簡易測試 (REPL)
- Right click src and select New 🢂 Scala Worksheet.
- Scala Worksheet 命名
- coding
- run Scala Worksheet
Scala 的 Maven : SBT simple build tool 來建立專案


- 專案結構

- .idea (IntelliJ files)
- project (plugins and additional settings for sbt)
- src (source files)
- main (application code)
- java (Java source files)
- scala (Scala source files) <-- This is all we need for now
- scala-2.12 (Scala 2.12 specific files)
- test (unit tests)
- target (generated files)
- build.sbt (build definition file for sbt)
- 範例程式撰寫
- On the Project panel on the left, expand SBTExampleProject 🢂 src 🢂 main
- Right-click scala and select New 🢂 Package
- Name the package example and click OK.
- Right-click the package example and select New 🢂 Scala class.
- Name the class Main and change the Kind to object.
- Change the code in the class as the following:
object Main extends App {
val ages = Seq(42, 75, 29, 64)
println(s"The oldest person is ${ages.max}")
}
- Run
- From the Run menu, select Edit configurations
- Click the + button and select SBT Task.
- Name it Run the program.
- In the Tasks field, type ~run. The ~ causes SBT to rebuild and rerun the project when you save changes to a file in the project.
- Click OK.
- On the Run menu. Click Run ‘Run the program’.
- In the code, change 75 to 61 and look at the updated output in the console.



