本文专治:
1.国内“复杂”的网络环境,下载太慢
2.在代理环境下update出错
3.You probably access the destination server through a proxy server that is not well configured
其实最好的解决方法是搭建自己的nexus私服,即快即剩网速,请查看我的另一博客
nexus私服搭建详解
sbt结构简介
sbt下载地址:http://www.scala-sbt.org/download.html
下载后打开sbt目录,你会发现sbt的目录结构不是很复杂,包含bin和conf。下面对主要的文件进行介绍:
conf/sbtconfig.txt: sbt的配置文件:在这里我们可以配置代理。
conf/sbtopts:也是sbt的配置文件,主要包含配置设置ivy和boot的地址
bin/sbt-launch.jar: 最sbt的核心jar包
添加国内源
1.全局方式
在.sbt\repositories中修改
[repositories]
local
Nexus osc : http://maven.oschina.net/content/groups/public/
Nexus osc thirdparty : http://maven.oschina.net/content/repositories/thirdparty/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
http://repo.typesafe.com/typesafe/releases/
http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
http://oss.sonatype.org/content/repositories/snapshots
2.如果你只想在单个项目中生效的话,在build文件中添加:
resolvers += "osc" at "http://maven.oschina.net/content/groups/public/"
3.或者可以指定某一个依赖包的源
libraryDependencies += "slinky" % "slinky" % "2.1" from "http://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar"
添加代理
在conf/sbtconfig.txt:
在该文件中添加代理:
-Dhttp.proxyHost=proxy
-Dhttp.proxyPort=8080
具体详情:sbt官网文档
错误集锦
安装sbt-assembly出现:com.eed3si9n#sbt-assembly;0.13.0: not found
Typesafe 仓库转移至 Bintray:https://www.typesafe.com/blog/migrating-repos-to-bintray
因此在plugins.sbt 中添加:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
即可!