我注意到 scala 符合 jsr 223 https://issues.scala-lang.org/browse/SI-874 ...但是它能够做像 GroovyScriptEngine 这样的事情吗?我考虑为我们的产品添加 scala 脚本支持,以便开发人员可以编写从 Java 应用程序加载的小型应用程序/组件/类(理想情况下可以重新加载)。我将 GroovyScriptEngine 用于 groovy 应用程序/组件/类,但我在 Scala 中找不到类似的东西。
基本上,我需要为它提供一个包含 Scala 内容的目录,它会加载所有可访问(或至少一个)Java 应用程序的 Scala 类。
你能给我一些指点吗?这是我们使用 Scala 的唯一方法。
最佳答案
This library dynamically compiles scala source files and loads them as classes. Changed scala files will be recompiled and the changed class with be loaded. Multiple source paths are supported as well as compilation class path and class loading class paths (so that the scripts can load extra libraries).
Classpath detection can be automatic (effectively using the classpath of the caller) or manual.
Different compilation and refreshing strategies are provided to suit various purposes.
关于scala - Scala 中是否有 GroovyScriptEngine 和 GroovyClassLoader 之类的东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16122398/