【发布时间】:2015-09-16 00:00:54
【问题描述】:
如何从我的代码(Spring Boot 应用程序)访问存储在我的 src/main/resources 文件夹中的 freemarker 模板 (*.ftl) 文件?
我尝试了以下
freemarker.template.Configuration config = new Configuration();
configuration.setClassForTemplateLoading(this.getClass(), "/resources/templates/");
并得到以下异常
freemarker.template.TemplateNotFoundException: Template not found for name "my-template.ftl".
【问题讨论】:
-
如果您使用开箱即用的 Spring 配置,您实际上不需要执行任何操作。由于 Spring boot 为您配置免费标记,包括解析器。
标签: spring maven spring-boot freemarker