下载sbt:

http://www.scala-sbt.org/download.html

 

 sbt 学习笔记(1)sbt安装和交互式界面使用

解压zip文件F:\sbt-0.13.15

 

配置环境变量

sbt 学习笔记(1)sbt安装和交互式界面使用

 

sbt 学习笔记(1)sbt安装和交互式界面使用

如果需要可以修改F:\sbt-0.13.15\sbt\conf\sbtconfig.txt

#ivy的cache等,保存到指定的文件夹;不配置的话sbt下载的jar包都会默认放到C盘的用户目录下

#-Dsbt.boot.directory=F:/sbt-0.13.15/sbt/boot

#The directory defined here is used to store all cached JARs resolved launcher.

#-Dsbt.ivy.home=F:/sbt-0.13.15/sbt/.ivy2

#-Dsbt.override.build.repos=true
#-Dsbt.global.base=F:/sbt-0.13.15/sbt/.sbt

#代理设置

#-Dhttp.proxyHost=xxx.xxx.com  

#-Dhttp.proxyPort=xx

#-Dsbt.repository.config=F:/sbt-0.13.15/sbt/conf/repo.properties

建立repo.properties,添加阿里云

[repositories]

local

nexus-aliyun:http://maven.aliyun.com/nexus/content/groups/public

nexus-aliyun-ivy:http://maven.aliyun.com/nexus/content/groups/public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly

 

创建一个文件夹FirstSbtProject,构建以下目录

sbt 学习笔记(1)sbt安装和交互式界面使用

 

 

修改build.sbt 内容

 

name := "FirstSbtProject"

version := "1.0" 

scalaVersion := "2.10.6"

进入到项目根目录,输入sbt回车进入sbt交互模式, 第一次运行会比较慢,耐心等待,要下载相关的jars

sbt 学习笔记(1)sbt安装和交互式界面使用

输入help命令查询,即会列出一堆可用的命令

sbt 学习笔记(1)sbt安装和交互式界面使用

输入show name,看当前项目的名字,输入show libraryDependencies看当前项目依赖的库,libraryDependencies太长记不住?输入lib后按tab键,可列出相关内容

sbt 学习笔记(1)sbt安装和交互式界面使用

 

有一个强大的任务不得不特别拎出来说一下:console 
输入console回车,会在当前会话内启动一个Scala REPL

sbt 学习笔记(1)sbt安装和交互式界面使用

 

相关文章: