Spring Boot — How to hot swap Thymeleaf templates

This is an often-asked question on the Internet — and one which, previously, had no good answer. Now, thanks to @Jianrong Chen, we have a one-liner configuration to do it!


# Thymeleaf templates from filesystem, not cached

# static content from filesystem first, too

The magic here is to set ‘spring.thymeleaf.templates_root’ to load from the filesystem, rather than the classpath. This means the project no longer has to be built.. Thymeleaf picks up changed templates immediately.

The amazing thing is that apart from one tiny comment on Stack Overflow, this seems completely undocumented — the world is unaware of this.


Leave a Reply

Your email address will not be published. Required fields are marked *