centos7-- sbt的安裝使用

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
相關文章
相關標籤/搜索