使用sbt,idea 创建 scala 工程,记录一下
1、安装sbt,配置使用其他镜像地址
windows 7 环境
下载地址:https://www.scala-sbt.org/download.html
安装位置:D:\sbt
(安装成功后,sbt运行环境地址,D:\sbt\bin,一般会自动添加到环境变量中)
如果不修改默认配置,使用默认镜像,则下载环境依赖的jar包,会很慢,基本是失败;
打开 D:\sbt\conf\sbtconfig.txt,添加如下内容:
-Dsbt.log.format=true
-Dsbt.boot.directory=D:/sbt/.sbt/boot
-Dsbt.ivy.home=D:/sbt/.ivy2
-Dsbt.global.base=D:/sbt/.sbt
-Dsbt.repository.config=D:/sbt/conf/repository.properties
在D:\sbt\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
【 还有aliyun的另外一个地址:
aliyun-nexus: http://maven.aliyun.com/nexus/content/repositories/central/
我在使用的过程中,发现环境依赖的包,多数是从ibiblio-maven,uk-repository中下载的 】
创建scala工程目录,比如:F:\scala
命令行进入,输入:sbt new scala/hello-world.g8
第一次运行,会下载很多依赖包,需要等待较长时间;
接着,下载工程模板,如下所示:
进入工程目录hello-world,输入:sbt (会下载依赖的jar包)
输入:run 运行工程
2、IDEA,创建scala工程,使用独立安装的sbt环境;
首先安装idea scala插件;
配置,使用1步骤中,已经安装的sbt环境;