Scala REPL 导入 SBT 文件

3

我有一个SBT文件,其中包含以下内容:

name := "Scala Playground"

version := "1.0"

scalaVersion := "2.11.6"

resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies ++= Seq(
  "com.netflix.rxjava" %% "rxjava-scala" % "0.19.1",
  "com.typesafe.play"  %% "play-json"    % "2.2.1"
)

文件保存为scala-playground.sbt。我想在Scala REPL中使用它。当我尝试执行以下操作时:

sbt scala-playground.sbt

我遇到了以下错误:

[info] Set current project to Scala Playground (in build file:/home/joe/Desktop/)
[error] Not a valid command: scala-playground
[error] Not a valid project ID: scala-playground
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: scala-playground (similar: scala-version, scalac-options, scala-binary-version)
[error] scala-playground
[error]                 ^

我在我的sbt文件中没有看到任何愚蠢的地方。有人能帮我解释一下吗?这是在Scala REPL中获取依赖项的正确方法吗?

我想做的就是在我的Scala REPL中获取一些依赖项,以便我可以快速运行和评估某些库。

1个回答

6
命令行参数是sbt命令,而不是要使用的文件。只需转到包含scala-playground.sbt文件的目录并从那里运行即可:
sbt console

sbt 应该自动从当前目录加载 scala-playground.sbt 文件和打开 Scala 控制台。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接