我已使用Installing sbt on Linux中的说明安装了sbt。
$ sbt --version
sbt launcher version **0.13.8**
$ sbt console
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (OpenJDK 64-Bit Server VM, Java 1.7.0_79).
如何配置(或更新)sbt以便sbt console
使用最新的Scala版本 2.11.6 ?
答案 0 :(得分:6)
创建build.sbt
文件并输入scalaVersion
:
scalaVersion := "2.11.5"
在sbt console
的同一目录中运行build.sbt
,它将加载您指定的版本。
...:sbttest/ $ sbt console [10:55:53]
[info] Loading global plugins from /home/.../.sbt/0.13/plugins
[info] Set current project to sbttest (in build file:/tmp/sbttest/)
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
答案 1 :(得分:6)
使用build.sbt在同一目录下运行sbt console,它将加载您指定的版本。
您也可以将build.sbt
文件放在.sbt/0.13/
目录中:
cat <<END > ~/.sbt/0.13/build.sbt
scalaVersion := "2.11.8"
END
然后,从其他任何地方执行sbt console
将为您提供您最喜欢的scala
版本。 (如果您执行build.sbt
的目录中存在本地sbt
文件,则本地指定的版本将覆盖全局文件。
答案 2 :(得分:2)
sbt ++ 2.11.11 console
将2.11.11更改为您选择的Scala版本。
来自sbt help ++
:
++ <scala-version> [<command>]
Changes the Scala version and runs a command.
Sets the `scalaVersion` of all projects to <scala-version> and
reloads the build.
If <command> is provided, it is then executed.
++ [<scala-version>=]<scala-home> [<command>]
Uses the Scala installation at <scala-home> by configuring the
scalaHome setting for
all projects.
If <scala-version> is specified, it is used as the value of the
scalaVersion setting.
This is important when using managed dependencies. This version
will determine the
cross-version used as well as transitive dependencies.
If <command> is provided, it is then executed.
See also `help +`