1

I'm trying to give resource folder for Freemarker template below is my bean config

  Configuration freeMarkerConfig() throws IOException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_29);
    cfg.setDirectoryForTemplateLoading(new ClassPathResource("ftl").getFile());
    return cfg;
  }

and I have ftl folder in the resources folder

   -- java
   -- resources
       -- ftl
           -- template.ftl

while deploying it works fine in my local machine but fails in my docker container with exception

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

I need to keep ftl in the resources folder and give the directory path to configuration. I don't know how to debug further.

Ijaz
  • 421
  • 1
  • 6
  • 23

2 Answers2

1

I found the issue after repeated searching. Issue is because of this

Classpath resource not found when running as jar

Ijaz
  • 421
  • 1
  • 6
  • 23
0

Property spring.freemarker.template-loader-path is available.

spring.freemarker.template-loader-path=classpath:/ftl/

Or, use setTemplateLoaderPath("classpath:/ftl/") instead of setDirectoryForTemplateLoading().