sbt安装、配置、運行(scala sbt helloworld)

本文详细介绍了如何下载并配置SBT 1.1.6,包括环境变量设置、启动脚本编写及配置文件repo.properties的定制。通过这些步骤,可以顺利在本地环境中启动SBT,进行Scala项目的开发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载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 "$@"

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

~/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) appleyuchi@ubuntu:~/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
 

参考链接:

https://www.2cto.com/kf/201611/561556.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值