我项目的结构:
-src
--main
---java
----makers
-----SomeClass
---resources
----htmlPattern.vm
如何告诉SomeClass关于htmlPattern。我尝试这样的事情:
VelocityEngine ve = new VelocityEngine();
Properties properties = new Properties();
properties.setProperty("resource.loader", "file");
properties.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
properties.setProperty("file.resource.loader.path", "resources");
properties.setProperty("file.resource.loader.cache", "true");
properties.setProperty("file.resource.loader.modificationCheckInterval", "2");
ve.init(properties);
Template t = ve.getTemplate("htmlPattern.vm", "utf-8");
怎么了? IDE说:
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'htmlPattern.vm'
答案 0 :(得分:5)
我解决了我的问题。
VelocityEngine ve = new VelocityEngine();
Properties properties = new Properties();
properties.setProperty("resource.loader", "file");
properties.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
ve.init(properties);