Search code examples
spring-bootfreemarker

Load freemarker templates from folder outside of classpath


I'm adding this configuration to my project:

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

Spring loading tells me the path does not exist, but it does.

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)

If I use the standard configuration it works fine.

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

Solution

  • can you try with file:/ before adding exact path location

    visit here http://www.sandc.software/blog/how-to-load-freemarker-templates-from-external-file-system-folder-with-spring-boot/