【发布时间】:2020-10-12 21:29:24
【问题描述】:
我正在尝试为下面的 Freemarker 模板提供资源文件夹是我的 bean 配置
配置 freeMarkerConfig() 抛出 IOException {
配置 cfg = 新配置(Configuration.VERSION_2_3_29);
cfg.setDirectoryForTemplateLoading(new ClassPathResource("ftl").getFile());
返回配置文件;
}
我在资源文件夹中有 ftl 文件夹
-- java
-- resources
-- ftl
-- template.ftl
虽然部署它在我的本地机器上运行良好,但在我的 docker 容器中失败并出现异常
java.io.FileNotFoundException: class path resource [ftl] cannot be resolved to absolute file
path because it does not reside in the file system: jar:file:!/BOOT-INF/classes!/ftl
我需要将 ftl 保存在资源文件夹中,并给出配置的目录路径。我不知道如何进一步调试。
【问题讨论】: