从类路径外的文件夹加载 freemarker 模板

Load freemarker templates from folder outside of classpath

我正在将此配置添加到我的项目中:

#freemarker
spring.freemarker.prefer-file-system-access=true
spring.freemarker.template-loader-path=/Users/leo/dev/project/templates/

Spring加载告诉我路径不存在,但确实存在。

2016-12-30 11:47:09.791  WARN 3430 --- [           main] o.s.b.a.f.FreeMarkerAutoConfiguration    : Cannot find template location(s): [/Users/leo/dev/project/templates/] (please add some templates, check your FreeMarker configuration, or set spring.freemarker.checkTemplateLocation=false)

如果我使用标准配置,它工作正常。

#freemarker
spring.freemarker.template-loader-path=classpath:/templates/

你能在添加确切路径位置之前尝试使用 file:/ 吗

访问此处http://www.sandc.software/blog/how-to-load-freemarker-templates-from-external-file-system-folder-with-spring-boot/