sbt是一款相似于maven的构建工具 #安装sbt curl https://bintray.com/sbt/rpm/rpm > bintray-sbt-rpm.repo mv bintray-sbt-rpm.repo /etc/yum.repos.d/ yum install sbt -y 配置其使用国内阿里云仓库源 在 .sbt下新建repositories文件vim
vim /root/.sbt/repositories [repositories] local aliyun: http://maven.aliyun.com/nexus/content/groups/public jcenter: http://jcenter.bintray.com typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
#简单使用 构建hello项目curl
mkdir -p /root/project_sbt/hello vim /root/project_sbt/hello/hw.scala #项目代码 object Hi { def main(args: Array[String]) = println("Hi!") } vim /root/project_sbt/hello/build.sbt #构建定义,相似于maven的pom.xml lazy val root = (project in file(".")) .settings( name := "hello", version := "1.0", scalaVersion := "2.12.2" )
开始打包maven
cd /root/project_sbt/hello sbt clean package 也能够sbt回车,出现一个交互界面,再clean package ls /root/project_sbt/hello/target/scala-2.12 drwxr-xr-x 2 root root 39 Jan 28 11:52 classes -rw-r--r-- 1 root root 1376 Jan 28 11:52 hello_2.12-1.0.jar drwxr-xr-x 4 root root 34 Jan 28 11:52 resolution-cache