First of all, this question has been asked before here,here and here but none of the answers could help me. I just created an example project to test velocity:
public static void main(String[] args) throws IOException {
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty("resource.loader", "class");
velocityEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
velocityEngine.init();
VelocityContext context = new VelocityContext();
context.put("name", "World");
Template template = Velocity.getTemplate("test.vm");
Writer writer = new OutputStreamWriter(System.out);
template.merge(context, writer);
writer.close();
}
The template test.vm
is in the same folder as the mainclass. I get always ResourceNotFoundException
when trying to run this program. According to the docs and answers in the previous questions this should work. Any Ideas why it does not?
p.s. I also tried the other properties suggested in the answers.