[英]Apache velocity: org.apache.velocity.exception.ResourceNotFoundException
I am following http://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.html tutorial. 我正在关注http://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.html教程。
I have kept my vm
file in the same folder as of my class. 我将我的
vm
文件保存在与我班级相同的文件夹中。 I am getting the following exception: 我收到以下异常:
Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource
As velocity
documentation says I need JSP/servlet
support which I don't have right now. 正如
velocity
文档所说,我需要JSP/servlet
支持,而我现在还没有。
Where am I going wrong? 我哪里错了?
PS: I am using IntelliJ IDE
PS:我正在使用
IntelliJ IDE
Try setting RuntimeConstants.RESOURCE_LOADER
and classpath.resource.loader.class
in your Velocity engine to look in your source code: 尝试在Velocity引擎中设置
RuntimeConstants.RESOURCE_LOADER
和classpath.resource.loader.class
来查看源代码:
VelocityEngine engine = new VelocityEngine();
engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName())
//this is at src/main/java level, tested with Netbeans
Template yourTemplate = ve.getTemplate("yourTemplate.vm");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.