Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable hot refresh of freemarker templates in spring boot?

I'm looking for enabling hot refresh of ftl files on spring boot framework, so that changes on ftl files need not require application restart. I had tried following settings through application.properties,

spring.freemarker.cache=false
spring.freemarker.template_update_delay=0

but yet still not getting to it.

How can I enable it through application properties?

thanks!

like image 875
everlasto Avatar asked Mar 28 '15 06:03

everlasto


People also ask

How do I use FreeMarker template in spring boot?

Freemarker Template Files Spring boot looks for the The template files under classpath:/templates/. And for the file extension, you should name the files with . ftlh suffix since Spring Boot 2.2. If you plan on changing the location or the file extension, you should use the following configurations.

How do I comment in FreeMarker template?

Comments: <#-- and --> Comments are similar to HTML comments, but they are delimited by <#-- and -->. Comments will be ignored by FreeMarker, and will not be written to the output.

What is the use of FreeMarker template?

FreeMarker is a template engine, written in Java, and maintained by the Apache Foundation. We can use the FreeMarker Template Language, also known as FTL, to generate many text-based formats like web pages, email, or XML files.

What is spring FreeMarker?

FreeMarker is a server-side Java template engine for both web and standalone environments. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language. Note: Spring Boot recently changed the default extension from . ftl to .


2 Answers

I'm using SpringBoot with maven and I have the same problem. I just discovered that the templates are in target/classes/templates so after modifying a template you have to rebuild the project to reinstall the template in classes. This works for me.

like image 120
den Avatar answered Oct 08 '22 17:10

den


Even i faced the same problem. Tried opening in incognito mode. Tried setting browser cache to false. Nothing worked.

Now i copy and paste whatever changes i make to the original ftl to the target folder's ftls

enter image description here

like image 24
gursahib.singh.sahni Avatar answered Oct 08 '22 15:10

gursahib.singh.sahni