Linux无坑安装sbt

本文详细介绍如何下载并配置Sbt及其国内仓库,包括下载Sbt、上传与解压安装包、设置国内仓库地址及修改配置文件的过程,有效提升打包编译速度。

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

下载

sbt下载:https://sbt-downloads.cdnedge.bluemix.net/releases/v1.3.0/sbt-1.3.0.zip

下载完用rz工具把安装包上传到虚拟机,然后解压

注意.zip后缀的压缩包用unzip命令解压

sudo unzip -q sbt-1.3.0.zip
设置国内仓库

默认情况下,sbt使用的是国外的仓库地址,打包编译的时候慢的一匹(无法忍受),为了加快打包编译速度,建议更换仓库地址。

mkdir ~/.sbt
cd ~/.sbt
vim repositories

输入如下内容

[repositories]
aliyun-maven-repo: https://maven.aliyun.com/repository/public
aliyun-nexus: https://maven.aliyun.com/nexus/content/groups/public/
typesafe: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
maven-central
sonatype-oss-releases
sonatype-oss-snapshots
ivy-sbt-plugin: https://dl.bintray.com/sbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

然后,修改SBT配置文件。打开/usr/local/sbt-1.3/conf/sbtopts 文件(conf文件夹在sbt的安装目录下),在末尾新增一行

-Dsbt.override.build.repos=true
配置环境变量
vim ~/.bashrc

添加

export PATH=$PATH:/usr/local/sbt-1.3/bin
运行
sbt sbtVersion

开始执行这一步的时候,如果没有配置国内仓库,它会从国外的仓库安装很多依赖包(巨慢),这就体现出了sbt配置国内仓库的重要性了。等依赖包下载完后,它会在控制台打印出sbt的安装版本。
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值