编译成jar文件
MacBook-Air:Documents myhaspl$ mkdir hello MacBook-Air:Documents myhaspl$ cd hello MacBook-Air:hello myhaspl$ ls MacBook-Air:hello myhaspl$ pwd /Users/lxxxxx/Documents/hello MacBook-Air:hello myhaspl$ vim HelloWorld.scala MacBook-Air:hello myhaspl$ cat HelloWorld.scala object HelloWorld{ def main(args: Array[String]) { println("Hello, SBT") } } MacBook-Air:hello myhaspl$ ls HelloWorld.scala MacBook-Air:hello myhaspl$ sbt [warn] No sbt.version set in project/build.properties, base directory: /Users/lzzzz/Documents/hello [info] Set current project to hello (in build file:/Users/liuxing/Documents/hello/) [info] sbt server started at local:///Users/zzzz/.sbt/1.0/server/acaf9a819c75648cf68d/sock sbt:hello> run [info] Updating ... [info] Done updating. [info] Compiling 1 Scala source to /Users/zzz/Documents/hello/target/scala-2.12/classes ... [info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.7. Compiling... [info] Compilation completed in 15.127s. [info] Done compiling. [info] Packaging /Users/zzzz/Documents/hello/target/scala-2.12/hello_2.12-0.1.0-SNAPSHOT.jar ... [info] Done packaging. [info] Running HelloWorld Hello, SBT [success] Total time: 30 s, completed Oct 10, 2018 8:02:55 PM sbt:hello> MacBook-Air:hello myhaspl$ vim build.sbt MacBook-Air:hello myhaspl$ cat build.sbt name := "hello" // 项目名称 organization := "myhaspl.com" // 组织名称 version := "0.0.1" // 版本号 scalaVersion := "2.12.7" // 使用的Scala版本号 MacBook-Air:hello myhaspl$ sbt:hello> compile [info] Updating ... [info] Done updating. [success] Total time: 1 s, completed Oct 10, 2018 8:20:26 PM sbt:hello> package [info] Packaging /Users/xxxxx/Documents/hello/target/scala-2.12/hello_2.12-0.0.1.jar ... [info] Done packaging. [success] Total time: 0 s, completed Oct 10, 2018 8:20:35 PM MacBook-Air:scala-2.12 myhaspl$ scala hello_2.12-0.0.1.jar Hello, SBT