SBT--入门并在IDEA中使用
SBT简介
SBT(Simple Build Tool
),对于SBT,官网是这样介绍的”The interactive build tool,Use Scala to define your tasks. Then run them in parallel from the shell.
“。即是一个现代构建工具,它是用Scala编写的,对编译Scala、Spark项目提供了不错的支持。和Maven一样它也是一个通用的构建工具。
SBT安装
- 下载:http://www.scala-sbt.org/release/docs/Setup.html,下载后目录如下,只有两个目录
bin
和conf
配置环境变量:
SBT_HOME=D:\dev\sbt
%SBT_HOME%\bin;修改配置文件:sbtconfig.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20# Set the java args to high
-Xmx512M
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=128m
# Set the extra SBT options
-Dactivator.checkForUpdates=false
-Dsbt.log.format=true
-Dhttp.proxyHost=proxy.tencent.com
-Dhttp.proxyPort=8080
-Dhttps.proxyHost=proxy.tencent.com
-Dhttps.proxyPort=8080
# 设置boot目录以及ivy本地仓库地址
-Dsbt.boot.directory=D:/dev/sbt/boot/
-Dsbt.ivy.home=D:/dev/sbt/ivy2/
-Dsbt.repository.config=D:/dev/sbt/conf/repo.properties在conf目录下创建repo.properties文件,内容如下
1
2
3
4
5
6
7
8
9
10
11
12[repositories]
local
ui:http://uk.maven.org/maven2/
ui-ivy:http://uk.maven.org/maven2/,[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
typesafe:http://repo.typesafe.com/typesafe/releases/
typesafe-ivy: http://repo.typesafe.com/typesafe/ivy-releases/,[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sbt-plugin: http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
sonatype: http://oss.sonatype.org/content/repositories/snapshots
repo2: http://repo2.maven.org/maven2/
SBT运行
- 测试一下:
如果不配置repo.properties文件,默认会去 https://repo1.maven.org/maven2/地址下载jar。
在IDEA中使用
安装:idea 安装配置SBT,点击install安装后重启IDEA
配置idea:如果不配置,
SBT_HOME
下面的配置是对idea无效的,有两种方式
- 第一种:解压sbt-launch.jar,修改里面的sbt.boot.properties文件,在repositories配置项中添加镜像配置重新打包(这里就不做具体说明)
- 第二种:
2.1. 在idea配置
2.2. 在用户目录下的.sbt文件夹下,创建一个repositories文件,文件内容为镜像文件repo.properties的内容。
创建SBT项目
- 参考资料
http://www.scala-sbt.org/release/docs/zh-cn/Getting-Started.html
http://blog.csdn.net/cjuexuan/article/details/51148002
http://blog.csdn.net/jameshadoop/article/details/52295710
上一篇:SBT--Error during sbt execution: Error retrieving required libraries