I am following http://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.html tutorial.
I have kept my vm
file in the same folder as of my class. 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.
Where am I going wrong?
PS: I am using IntelliJ IDE
Try setting RuntimeConstants.RESOURCE_LOADER
and classpath.resource.loader.class
in your Velocity engine to look in your source code:
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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.