Ois,
li uns artigos sobre velocity, e tentei executar um Hello WOrld, porém, aparece um erro de q o arquivo.vm nao foi encontrado:
Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'template1.vm'
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:45
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:341)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:831)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:813)
at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:470)
at VelocityListProcess.main(VelocityListProcess.java:15)
O template está no mesmo diretorio do arquivo .java
HelloWorld.java:
public class HelloWorld {
public static void main(String[] args) throws Exception {
VelocityEngine ve = new VelocityEngine();
ve.init();
Template t = ve.getTemplate("helloworld.vm");
VelocityContext context = new VelocityContext();
context.put("name", "World");
StringWriter writer = new StringWriter();
t.merge(context, writer);
System.out.println(writer.toString());
}
}
Esqueci de fazer alguma coisa??