Spring Boot Template Engine Hot Deployment Techniques
This article explains how to disable template engine caching and use various hot‑deployment methods—including property settings, Debug mode, spring‑boot‑devtools, Spring Loaded, and JRebel—to achieve real‑time updates of Spring Boot web pages.
In Spring Boot, template engines such as Thymeleaf, FreeMarker, Groovy, and Velocity cache pages by default, so changes are not reflected after a refresh; disabling the cache in application.properties solves this.
1. Disable cache via properties: Thymeleaf: spring.thymeleaf.cache=false FreeMarker: spring.freemarker.cache=false Groovy: spring.groovy.template.cache=false Velocity: spring.velocity.cache=false
2. Debug mode hot deployment: Run the application in Debug mode for the simplest and fastest hot‑reload, though it cannot handle changes to configuration files, method names, or added classes.
3. spring‑boot‑devtools: Adding the spring-boot-devtools dependency enables automatic restart and live reload for both templates and code. Example dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>This approach covers all changes, including configuration files, but restarts the application on file changes, which may affect experience.
4. Spring Loaded: Similar to Debug mode but works without starting the JVM in Debug; it requires adding the Spring Loaded agent to the run configuration.
5. JRebel: A commercial Java hot‑deployment tool that offers extensive support for Spring Boot; it provides a 14‑day trial and can be installed via plugin.
Additional links at the end point to related technical articles and a large collection of interview questions covering many backend technologies.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.