sbt的实质是从网上下载项目需要的jar包,所以在配置和使用时必须保证能ping域名,除非再次打包时example.sbt中没有添加新的ar包。
1、sbt解压到指定路径,配置环境变量,source
2、执行sbt package或sbt version,执行后会一直get ***,并在~目录下产生.sbt目录
3、Ctrl+C退出geting
4、cd ~
5、cd .sbt
6、将sbt默认的国外mvn源换为国内的阿里源和gtan源以及各种其他源?,这样下载速度会比较快
vim repositories
在此new file中添加如下内容:
[repositories]
local
aliyun: http://maven.aliyun.com/nexus/content/groups/public/
repox-maven: http://repox.gtan.com:8078/
repox-ivy: http://repox.gtan.com:8078/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
Nexus osc : https://code.lds.org/nexus/content/groups/main-repo
Nexus osc thirdparty : https://code.lds.org/nexus/content/groups/plugin-repo/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
typesafe2: http://repo.typesafe.com/typesafe/releases/
sbt-plugin: http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
sonatype: http://oss.sonatype.org/content/repositories/snapshots
uk_maven: http://uk.maven.org/maven2/
ibibli: http://mirrors.ibiblio.org/maven2/
repo2: http://repo2.maven.org/maven2/
comp-maven:http://mvnrepository.com/artifact/
store_cn:http://maven.oschina.net/content/groups/public/
store_mir:http://mirrors.ibiblio.org/maven2/
store_0:http://maven.net.cn/content/groups/public/
store_1:http://repo.typesafe.com/typesafe/ivy-releases/
store_2:http://repo2.maven.org/maven2/
sbt-releases-repo: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sbt-plugins-repo: http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
maven-central: http://repo1.maven.org/maven2/
central: http://repo1.maven.org/maven2/
注意:在下一步的sbt package时如果网络不好,会导致重复下载jar包或丢失jar包,很容易产生ClassNotFound的error,或者只删除.ivy2目录也会产生error:ClassNotFound。这时通常把.sbt与.ivy2两个目录(注意两个目录都在~目录下,且目录以“.”开头)删除,因为通过网络下载的jar包通常缓存在这两个目录下。再从第2步重新开始。
7、sbt package,最后成功会出现下图。
参考这里