Gary's Blog

Hot reload Spring Boot Freemarker and Thymeleaf template on Idea IDE

  1. First of all, import Spring Boot devtools dependency to pom.xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
  1. Disable cache for template, if you use Freemarker template:
spring:
  freemarker:
    cache: false

if you use Thymeleaf template:

spring:
  thymeleaf:
    cache: false

So far, we had turned on the hot reload, but we need manually force reload by press

  1. Open Idea, open Prefrences, turn on auto compile.

  1. Also in Idea IDE, select menu Help -> Find Action, then type registry to open Registry settings,

Set compiler.automake.trigger.delay to 5 (seconds):

After that, the IDE will trigger reload every 5 seconds.

If you want to force reload (compile), you can still press keyboard CTRL + F9 or Command + F9 on Mac;

References:

  1. Intellij IDEA – Spring boot reload static file is not working
  2. 80. Hot swapping – Spring Boot
Exit mobile version