简体   繁体   English

Apache velocity:org.apache.velocity.exception.ResourceNotFoundException

[英]Apache velocity: org.apache.velocity.exception.ResourceNotFoundException

I am following http://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.html tutorial. 我正在关注http://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.html教程。

I have kept my vm file in the same folder as of my class. 我将我的vm文件保存在与我班级相同的文件夹中。 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. 正如velocity文档所说,我需要JSP/servlet支持,而我现在还没有。

Where am I going wrong? 我哪里错了?

PS: I am using IntelliJ IDE PS:我正在使用IntelliJ IDE

Try setting RuntimeConstants.RESOURCE_LOADER and classpath.resource.loader.class in your Velocity engine to look in your source code: 尝试在Velocity引擎中设置RuntimeConstants.RESOURCE_LOADERclasspath.resource.loader.class来查看源代码:

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"); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.apache.velocity.exception.ResourceNotFoundException - org.apache.velocity.exception.ResourceNotFoundException Velocity模板-线程“ main”中的异常org.apache.velocity.exception.ResourceNotFoundException:无法找到资源 - Velocity Template - Exception in thread “main” org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource org.apache.velocity.exception.ResourceNotFoundException:无法找到资源“模板/电子邮件/test.vm” - org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'templates/email/test.vm' 如何在模式生成期间修复“org.apache.velocity.exception.ResourceNotFoundException” - How to fix “org.apache.velocity.exception.ResourceNotFoundException” during schema generating 线程“主”中的异常org.apache.velocity.exception.VelocityException - Exception in thread “main” org.apache.velocity.exception.VelocityException Velocity中的ResourceNotFoundException - ResourceNotFoundException in Velocity Velocity 2.0:NoClassDefFoundError:org / apache / velocity / runtime / log / CommonsLogLogChute - Velocity 2.0: NoClassDefFoundError: org/apache/velocity/runtime/log/CommonsLogLogChute 使用Apache Velocity生成网站 - Generate Websites with Apache Velocity 速度与Apache Tiles - Velocity vs Apache Tiles 计算Apache速度中的哈希图 - Evaluating an hashmap in apache velocity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM