1. 程式人生 > 實用技巧 >sbt換源

sbt換源

sbt換源

目錄

兩種方法不一定都能用

方法一

Linux系統,則進入Bash執行如下命令:

cd  ~
mkdir  .sbt
cd  .sbt

然後建立 repositories 檔案內容如下,並將檔案拷貝到 .sbt 目錄下

[repositories]
local
huaweicloud-maven: https://repo.huaweicloud.com/repository/maven/
maven-central: https://repo1.maven.org/maven2/
sbt-plugin-repo: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

開啟 sbt-1.3.0/conf/sbtopts 檔案(不同機器位置不同,請自行尋找),在末尾新增一行,內容如下:

-Dsbt.override.build.repos=true

方法二

下載sbt-launch.jar包

wget http://maven.aliyun.com/nexus/content/repositories/central/org/scala-sbt/sbt-launch/1.3.10/sbt-launch-1.3.10.jar

解壓並對其中的./sbt/sbt.boot.properties檔案進行修改,在[repositories]處改為以下內容,增添一條阿里雲映象

unzip -q ./sbt-launch.jar
vim ./sbt/sbt.boot.properties
 
[repositories]
  local
  aliyun: http://maven.aliyun.com/nexus/content/groups/public/
  central: http://repo1.maven.org/maven2/

重新打包

jar -cfM ./sbt-launch.jar . #在主目錄下進行

檢驗sbt是否可用

./sbt version