解决 SBT 无法下载依赖包

之前做过一个项目是用  sbt 管理依赖的,被坑得不要不要的。。

拉取依赖时总是提示无法连接,但用浏览器可以访问相应的网站(typesafe, jcenter)

提示的错误为:

 Server access Error: Connection timed out url=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.8/ivys/ivy.xml

捣鼓了半天终于找到了解决的方法——将依赖包的地址改成http协议(默认是https的)

找到sbt-launch.jar, 用解压工具打开,更改里面sbt目录下sbt.boot.properties文件,把https协议改成http协议即可,如果还不行可以再加上

[repositories]
  local
  oschina: http://maven.oschina.net/content/groups/public/  //如果改成http不行的加上这句
  jcenter: http://jcenter.bintray.com/
  typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/

更改后再重新打包即可。

如果用IDEA的话,在IDEA里下载好Scala的plugin,在路径 用户.IntelliJIdea15configpluginsScalalauncher 下可以找到sbt-launch.jar,按上面的方法更改sbt的配置即可。

在ubuntu下路径为

/home/username/.IntelliJIdea2016.1/config/plugins/Scala/launcher/sbt-launch.jar

 使用 nautilus 路径名 即可在该路径打开资源管理器

参考链接:

http://dblab.xmu.edu.cn/blog/maven-network-problem/

原文地址:https://www.cnblogs.com/hwencc/p/5300845.html