sbt 简介 配置 加速 问题解决

本文专治:
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)

即可!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值