Windows(IDEA的sbt配置)

Windows(IDEA的sbt配置)

scala,在idea上使用sbt来编译项目。
本文参考
参考1
参考2

1. 下载sbt

http://www.scala-sbt.org/download.html
我下载的是zip,切记:要记住解压的地址。我的是d:\tool\目录。

2.添加配置

打开D:\tool\sbt\conf\sbtconfig.txt,在最后添加下面几行配置,注意指定的目录和文件

-Dsbt.ivy.home=D:/tool/sbt/.ivy2
-Dsbt.global.base=D:/tool/sbt/.sbt
-Dsbt.repository.config=D:/tool/sbt/conf/repo.properties

第一行sbt.ivy.home指定了本地自定义的repository路径(如果不设置就是默认的用户目录C:\Users\Administrator.ivy2)

安装好后找到sbt的安装目录,在conf下新建repo.properties文件,填写下面内容,指定镜像站的地址:

[repositories]
 local
  comp-maven: http://repo.data.1verge.net/nexus/content/groups/public/
  store_cn: http://maven.oschina.net/content/groups/public/
  store_mir: http://mirrors.ibiblio.org/maven2/
  store_0: http://maven.net.cn/content/groups/public/
  store_1: http://repo.typesafe.com/typesafe/ivy-releases/
  store_2: http://repo2.maven.org/maven2/

在环境变量PATH中添加D:\sbt\tool\bin

IDEA中的配置

确保IDEA中安装了Scala组件(与之后的内容不一定是前后关系)

  • File->Setting->Plugins->scala 然后安装就可以了(如果没有的话就搜索,找到Scala然后install)在这里插入图片描述
  • 开启一个Scala程序的步骤:new一个project(Scala class),选择Scala,选择sbt。
  • 如果没有Scala class的话可以参考idea右键新建(new) 但是没有Scala class选项

在这里插入图片描述在这里插入图片描述

  • 然后就是命名什么的。

文件 -> 其他设置 -> 默认设置中如下设置在这里插入图片描述
且,VM parameters的内容为:

-XX:MaxPermSize=512M
-Dsbt.log.format=true
-Dsbt.global.base=D:/tool/sbt/.sbt
-Dsbt.ivy.home=D:/tool/sbt/.ivy2
-Dsbt.boot.directory=D:/tool/.sbt/boot/
-Dsbt.repository.config=D:/tool/sbt/conf/repo.properties

在这里插入图片描述

结束。

或者

在conf下新建repository.properties文件,

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

在sbtconfig.txt的末尾添加如下内容

-Dsbt.log.format=true
-Dsbt.boot.directory=D:tool/sbt/.sbt/boot
-Dsbt.ivy.home=D:tool/sbt/.ivy2
-Dsbt.global.base=D:tool/sbt/.sbt

-Dsbt.repository.config=D:tool/sbt/conf/repository.properties

以上路径是sbt的路径,注意要仔细检查路径,确定是自己的路径,以免出错。

进入cmd并启动sbt(sbt在安装时会将路径加入到你的Classpath中),在第一次启动时会让你选择continue或quit,选c。在这里插入图片描述
.然后会开始安装各种jar包,需要等待挺长时间。在这里插入图片描述
安装完之后,开始打开我们的IDEA,点file->settings,搜索sbt,在VM parameter选项那里添加-Dsbt.override.build.repos=true ,然后在Launcher选项那里选择custom,并添加自己的sbt launch.jar的位置,如D:tool\sbt\binsbt-launch.jar,至此,配置自己的sbt就完成了。
完成。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值