因爲SBT的倉庫在國外,所以在國內使用IDEA創建SBT項目非常慢。
解決辦法:修改SBT倉庫爲國內的地址。
1、添加配置文件
在SBT的倉庫路徑下新建repositories文件,注意:文件名爲repositories,沒有後綴。
例如:C:\Users\lenovo\.sbt\repositories
repositories文件內容如下所示:
[repositories]
local
osc: 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
2、添加配置參數
在IDEA中,打開菜單File | Settings | Build, Execution, Deployment | Build Tools | sbt,
在VM Parameters中增加-Dsbt.override.build.repos=true,
在Launcher(sbt-launch.jar)處選擇Custum,選擇自己的Scala安裝路徑中的sbt-launch.jar,
例如:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.3\plugins\Scala\launcher\sbt-launch.jar,
如下所示:
3、重啓IDEA
在控制檯Build頁面,單擊Reimport sbt Project菜單,如下圖所示:
可以看到已經從配置的新倉庫下載資源,如下圖所示: