Velocity 1.4

Hi all,

I have only one question. I'm trying to do the first step in using Velocity. All I do I've created a simple velocity template test.vm looks like "Test velocity by $name."
and a simple class

<code>
import java.io.StringWriter;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;

public class Test {
    public static void main( String[] args ) throws Exception {
       
1.     VelocityEngine ve = new VelocityEngine();
2.     ve.init();
3.     Template t = ve.getTemplate("test.vm");
4.     VelocityContext context = new VelocityContext();
5.     context.put("name");
7.     StringWriter writer = new StringWriter();
8.     t.merge( context, writer );
9      System.out.println( writer.toString() );
    }
}
</code>

I have an error when I try to debug it: Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'test.vm'

I've looked for it so I found out that I have to set classpath to destination where is velocity template exists. Although I tried it by "Module Settings...->Libraries->Add Classes", I still have this exception. What the point?

PS I know this question is really simple. If anybody'd take me right direction I'll be just happy.

Thanks a lot in advise.

Laura.

3 comments
Comment actions Permalink

I've just found out what the point: all files with the extension *.vm weren't copied to class directory. It's strange. Why don't it work after classpath was set?

0
Comment actions Permalink

Please check Settings | Compiler | Resource patterns. Apparently *.vm
isn't on the list

0

Please sign in to leave a comment.