編碼的世界 / 優質文選 / 財富

Windows下sbt安裝配置


2022年8月02日
-   

1.下載sbt
  • 官網:http://www.scala-sbt.org/download.html
  • CSDN:http://download.csdn.net/download/u014532217/10187174

2.配置環境
#SBT_HOME設置為sbt解壓目錄,例如:
SBT_HOME=C:Programssbt;

#在path中添加:
Path=%SBT_HOME%in;

3.sbt配置
在sbtconfsbtconfig.txt中末尾添加
-Dsbt.boot.directory=C:/Programs/sbt/data/.sbt/boot
-Dsbt.global.base=C:/Programs/sbt/data/.sbt
-Dsbt.ivy.home=C:/Programs/sbt/data/.ivy2
-Dsbt.repository.config=C:/Programs/sbt/conf/repo.properties
-Dsbt.repository.secure=false
# 設置代理
# -Dhttp.proxyHost=10.18.11.11
# -Dhttp.proxyPort=8080
# -Dhttp.proxyUser=xx
# -Dhttp.proxyPassword=xx
# -Dhttps.proxyHost=10.18.1111
# -Dhttps.proxyPort=8080
# -Dhttps.proxyUser=xx
# -Dhttps.proxyPassword=xx

如果有需要設置代理的話,將“#設置代理”下面的#號去掉,並添加相應的代理設置,#是注釋。
4.設置阿裏雲鏡像
國內的網絡環境複雜,阿裏雲還挺好用的,在sbtconf下新建repo.properties文件,內容為:
[repositories]
local
aliyun: http://maven.aliyun.com/nexus/content/groups/public/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central
sonatype-oss-snapshots

5.驗證
打開cmd,輸入sbt,如果出現類似下面的結果則表明安裝成功:
C:UsersPetterChen>sbt
"C:UsersPetterChen.sbtpreloadedorg.scala-sbtsbt"1.0.3"jarssbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:UsersPetterChenproject
[info] Set current project to petterchen (in build file:/C:/Users/PetterChen/)
[info] sbt server started at 127.0.0.1:4729
sbt:petterchen>

注意,第一次運行的時候,sbt需要下載一些東西,下載消耗時間看網絡情況狀態。sbt版本不同的話,最後的結果也可能不一樣,但是只要配置和網絡正常,最後都會進入sbt的控制台。

熱門文章