Linux中安装sbt

2022/6/25 5:19:30

本文主要是介绍Linux中安装sbt,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

sbt下载官网地址:https://www.scala-sbt.org/download.html

一、Ubuntu安装

echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install sbt

二、Centos安装

# remove old Bintray repo file
sudo rm -f /etc/yum.repos.d/bintray-rpm.repo
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo
sudo mv sbt-rpm.repo /etc/yum.repos.d/
sudo yum install sbt

三、测试

// 查看下载版本
// 第一次执行时,会下载一些文件包,然后才能正常使用,需要确保是联网的
sbt sbtVersion

新建scala源文件测试

object HelloScala extends App {
  println("Hello Scala")
}
sbt run

[root@alwaysdayone ~]# sbt run
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 1.8.0_281)
[info] loading project definition from /root/workspace/chisel_leaning/project
[info] set current project to chisel_leaning (in build file:/root/workspace/chisel_leaning/)
[info] compiling 1 Scala source to /root/workspace/chisel_leaning/target/scala-2.12/classes ...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.15. Compiling...
[info]   Compilation completed in 8.652s.
[info] running HelloScala 
Hello Scala

 



这篇关于Linux中安装sbt的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程