为了可以用Eclipse编译基于Scala的Spark Project,需要安装sbt
环境:OS X Yosemite 10.10.3
1.安装Xcode
因为要在终端用macports安装sbt,而Xcode是macports安装的前提,所以要先去APPstore下载Xcode,并安装其command line developer tools。
安装比较简单,详见:https://guide.macports.org/#installing
2.安装macports
去官网下载其安装包并安装,和安装QQ一样简单
详见:https://guide.macports.org/#installing
3.安装sbt
在终端下输入一下命令:
port install sbt
看到类似以下信息就算安装完了:
...这里省略很多log...downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/apply-macro/0.13.7/jars/apply-macro.jar ... [SUCCESSFUL ] org.scala-sbt#apply-macro;0.13.7!apply-macro.jar (9005ms) :: retrieving :: org.scala-sbt#boot-app confs: [default] 51 artifacts copied, 0 already retrieved (15709kB/378ms) Getting Scala 2.10.4 (for sbt)... downloading https://repo1.maven.org/maven2/org/scala-lang/jline/2.10.4/jline-2.10.4.jar ... [SUCCESSFUL ] org.scala-lang#jline;2.10.4!jline.jar (1589ms) :: retrieving :: org.scala-sbt#boot-scala confs: [default] 5 artifacts copied, 0 already retrieved (24459kB/195ms) [info] Set current project to hello (in build file:/Users/apple/Desktop/hello/)
4.跑个hello world
为了验证sbt是不是安装成功,我们跑个hello world试试
$ mkdir hello $ cd hello $ echo ‘object Hi { def main(args: Array[String]) = println("Hi!") }‘ > hw.scala $ sbt ... > run[info] Updating {file:/Users/apple/Desktop/hello/}hello...[info] Resolving org.fusesource.jansi#jansi;1.4 ...[info] Done updating.[info] Compiling 1 Scala source to /Users/apple/Desktop/hello/target/scala-2.10/classes...[info] Running Hi Hi![success] Total time: 4 s, completed Jul 8, 2015 11:17:46 AM
这是官网的示例,按照他的做并出现相同的结果就对了!
到此,mac下安装sbt就结束了。
时间: 2024-10-17 17:31:40