Hot reload Spring Boot Freemarker and Thymeleaf template on Idea IDE

336 Uncategorized Leave a Comment
  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

  • CTRL + F9 on Windows or *unix
  • Command + F9 on Mac
  1. Open Idea, open Prefrences, turn on auto compile.

Build project automaticlly

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

Open registry

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

Set auto make time

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

Leave a Reply

Your email address will not be published.

Name *