我正在尝试检查提供 JSR 223 实现和Compilable 支持的速度脚本引擎 2.0
Compilable 接口已在此过程中实现。
我使用罐子:velocity-engine-scripting-2.0.jar、velocity-1.7.jar、commons-collections-3.2.2.jar
从上一个答案我使用以下代码
//class org.apache.velocity.script.VelocityScriptEngine
final ScriptEngine engine = engineFactory.getScriptEngine();
if (engine instanceof Compilable) {
try {
((Compilable) engine).compile("");
...
对于速度,我得到以下信息:
javax.script.ScriptException: org.apache.velocity.exception.ResourceNotFoundException: No template name provided
at org.apache.velocity.script.VelocityScriptEngine.compile(VelocityScriptEngine.java:311)
at org.apache.velocity.script.VelocityScriptEngine.compile(VelocityScriptEngine.java:288)
at com.Workers.LevelCheck.main(LevelCheck.java:69)
Caused by: org.apache.velocity.exception.ResourceNotFoundException: No template name provided
at org.apache.velocity.runtime.resource.loader.StringResourceLoader.getResourceStream(StringResourceLoader.java:353)
at org.apache.velocity.Template.process(Template.java:108)
at org.apache.velocity.script.VelocityScriptEngine.compile(VelocityScriptEngine.java:306)
... 2 more
此外,当我尝试给出模板名称((Compilable) engine).compile("v.vm");
时,它失败了,同样的异常