对于 Scala 2.12.x,可以使用scala.tools.nsc.interpreter.ILoop
嵌入 Scala REPL。Scala 2.13.x scala.tools.nsc.interpreter.ILoop
已被删除。如何嵌入 Scala 2.13.x REPL?
问问题
155 次
1 回答
2
尝试添加scala-compiler
依赖
libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.13.1"
之后,例如,以下编译
import scala.tools.nsc.interpreter.shell.{ILoop, ShellConfig}
import scala.tools.nsc._
object EmbeddedREPL extend App {
val settings = new Settings {
usejavacp.value = true
deprecation.value = true
}
val config = ShellConfig(settings)
new ILoop(config).run(settings)
}
于 2020-01-18T17:58:49.860 回答