#sbt下載慢的問題
默認情況下,sbt使用mvn2倉庫下載依賴,如下載scalatest時,idea的sbtshell 顯示如下url
此源速度很慢,用瀏覽器可以直接打開並測試速度,發現呵呵。
兩種覆蓋默認mvn2倉庫解決方案,使用阿里雲鏡像
1.項目覆蓋
resolvers += "central" at "http://maven.aliyun.com/nexus/content/groups/public/"
externalResolvers :=
Resolver.withDefaultResolvers(resolvers.value, mavenCentral = false)
2.全局覆蓋
在~/.sbt/repositories添加如下內容(如果沒有則創建這個文件)
[repositories]
local
my-maven-repo: http://maven.aliyun.com/nexus/content/groups/public
完成后,當在build.sbt添加依賴時,在idea的sbtShell可以看到如下內容
[info] downloading http://maven.aliyun.com/nexus/content/groups/public/junit/junit/4.2/junit-4.2-sources.jar ...
[info] [SUCCESSFUL ] junit#junit;4.2!junit.jar(src) (1011ms)
[info] Writing structure to /tmp/sbt-structure.xml...
[info] Done.
這就表明更換鏡像成功了,另外,sbt解析依賴過程也稍微耗時,不可能修改build.sbt后立即完成
dump project structure from sbt 過程
ps:官方文檔
https://www.scala-sbt.org/0.13.2/docs/Detailed-Topics/Library-Management.html#override-all-resolvers-for-all-builds
更新
之前spark的jar包在阿里鏡像上找不到,解析報錯,於是又嘗試了華為的鏡像,可以正常使用,鏈接如下,在里面找到sbt即可
https://mirrors.huaweicloud.com/
推薦一個穩定速度還行的國外源
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly