Apache Velocity 2.0 脚本编译不工作
Apache Velocity 2.0 Scripting Compilable not working
我正在尝试检查提供 JSR 223 实现和 support of Compilable
的速度脚本引擎 2.0
the Compilable interface has been implemented in the process.
我使用 jars: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");
它失败并出现相同的异常
您不能将 velocity-engine-scripting-2.0.jar 与 velocity-1.7.jar 一起使用,否则您需要使用 velocity-engine-core-2.0.jar你会得到不可预测的结果。
我正在尝试检查提供 JSR 223 实现和 support of Compilable
的速度脚本引擎 2.0the Compilable interface has been implemented in the process.
我使用 jars: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");
它失败并出现相同的异常
您不能将 velocity-engine-scripting-2.0.jar 与 velocity-1.7.jar 一起使用,否则您需要使用 velocity-engine-core-2.0.jar你会得到不可预测的结果。