sbt卡住的解决办法,sbt设置代理

121

方法一:设置国内源(失败)

  1. 创建~/.sbt/repositories文件。
  2. 写入
[repositories]
local
aliyun: http://maven.aliyun.com/nexus/content/groups/public
typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central
sonatype-oss-snapshots

  1. IDEA->Preferences -> BuildTool -> sbt -> VM parametes添加
-Dsbt.override.build.repos=true
-Dsbt.repository.config=~/.sbt/repositories

方法二:设置代理(解决)

注意:sbt会自动使用IDEA的代理设置,如果sbt可用那就不需要单独为sbt设置代理,但是由于sbt特别需要https代理,所以大多数时候需要单独设置。

IDEA的代理设置

1.使用socks代理(未解决)

IDEA->Preferences -> BuildTool -> sbt -> VM parametes添加

-DsocksProxyHost=127.0.0.1
-DsocksProxyPort=7070

理论上讲直接使用socks代理是最方便的,但我在使用的过程中未连接成功。

2.使用http+https代理(解决)

非常重要!必须同时设置http和https代理,单独一个仍然不行。(或许只用https也行)

IDEA->Preferences -> BuildTool -> sbt -> VM parametes添加

-DhttpProxyHost=127.0.0.1
-DhttpProxyPort=7890
-DhttpsProxyHost=127.0.0.1
-DhttpsProxyPort=7890

sbt的代理设置