1. 程式人生 > >sbt安裝、配置、執行(scala sbt helloworld)

sbt安裝、配置、執行(scala sbt helloworld)

下載sbt-1.1.6.tgz

---------------------------------------------------------------------------------------------------------------------------------------------------

.bashrc

export PATH=~/bigdata/sbt:$PATH
alias sbt=~/bigdata/sbt/bin/sbt

---------------------------------------------------------------------------------------------------------------------------------------------------

~/bigdata/sbt/start.sh

#!/bin/bash
SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"
java $SBT_OPTS -jar ~/bigdata/sbt/bin/sbt-launch.jar "[email protected]"

---------------------------------------------------------------------------------------------------------------------------------------------------

~/bigdata/sbt/conf/repo.properties

  [repositories]  
  local
  Nexus osc : https://code.lds.org/nexus/content/groups/main-repo
  Nexus osc thirdparty : https://code.lds.org/nexus/content/groups/plugin-repo/
  typesafe: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly  
  typesafe2: https://repo.typesafe.com/typesafe/releases/
  sbt-plugin: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
  sonatype: https://oss.sonatype.org/content/repositories/snapshots  
  uk_maven: https://uk.maven.org/maven2/  
  ibibli: https://mirrors.ibiblio.org/maven2/  
  repo2: https://repo2.maven.org/maven2/
 
  comp-maven:https://mvnrepository.com/artifact/
  store_cn:https://maven.oschina.net/content/groups/public/
  store_mir:https://mirrors.ibiblio.org/maven2/
  store_0:https://maven.net.cn/content/groups/public/
  store_1:https://repo.typesafe.com/typesafe/ivy-releases/
  store_2:https://repo2.maven.org/maven2/
 
  sbt-releases-repo: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  sbt-plugins-repo: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  maven-central: https://repo1.maven.org/maven2/

----------------------------------------------------------------------------------------------------------------------------------------------------------------

~/bigdata/sbt/conf/sbtconfig.txt

# Set the java args to high

-Xmx512M

-XX:MaxPermSize=256m

-XX:ReservedCodeCacheSize=128m



# Set the extra SBT options

-Dsbt.log.format=true

-Dsbt.boot.directory=~/bigdata/sbt/.sbt/boot
-Dsbt.global.base=~/bigdata/sbt/.sbt
-Dsbt.ivy.home=~/bigdata/sbt/.ivy2
-Dsbt.repository.config=~/bigdata/sbt/conf/repo.properties
-Dsbt.repository.secure=false

感覺上面的那個啟動指令碼也不是很必要,

按照上面這樣配置完以後,重新開啟終端,輸入sbt就可以啟動了

---------------------------------------------------------------------------------------------------------------------------------------------------

建立一個檔案叫test.

object HelloWorld{
  def main(args: Array[String]) {
    println("Hello, SBT")
  }

}

---------------------------------------------------------------------------------------------------------------------------------------------------

在當前路徑下啟動sbt

(python2.7) [email protected]:~/Learning-Spark/chapter10$ sbt [info] Updated file /home/appleyuchi/Learning-Spark/chapter10/project/build.properties: set sbt.version to 1.1.6 [info] Loading project definition from /home/appleyuchi/Learning-Spark/chapter10/project [info] Updating ProjectRef(uri("file:/home/appleyuchi/Learning-Spark/chapter10/project/"), "chapter10-build")... [info] Done updating. [info] Set current project to chapter10 (in build file:/home/appleyuchi/Learning-Spark/chapter10/) [warn] sbt server could not start because there's another instance of sbt running on this build. [warn] Running multiple instances is unsupported sbt:chapter10> run [info] Packaging /home/appleyuchi/Learning-Spark/chapter10/target/scala-2.12/chapter10_2.12-0.1.0-SNAPSHOT.jar ... [info] Done packaging. [info] Running HelloWorld Hello, SBT  

參考連結: