Master Spring Boot DevTools: Complete Guide to Hot Reload Configuration

This guide walks you through configuring Spring Boot DevTools for automatic restart and live reload, covering Maven dependencies, plugin settings, IDE options, application property examples, usage caveats, verification steps, and alternative tools for advanced hot deployment.

Ray's Galactic Tech
Ray's Galactic Tech
Ray's Galactic Tech
Master Spring Boot DevTools: Complete Guide to Hot Reload Configuration

Quick Configuration Steps

Add Dependency : Include the DevTools starter in

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
  </dependency>

to keep it out of production builds.

Maven Plugin Configuration : Set <fork>true</fork> inside the spring-boot-maven-plugin so DevTools can trigger a restart.

Enable Automatic Compilation in IDEA : Navigate to Build, Execution, Deployment → Compiler and check Build project automatically .

Allow Runtime Compilation : Open IDEA Registry (Ctrl+Shift+Alt+/ or Cmd+Shift+Option+/) and enable compiler.automake.allow.when.app.running. The location may vary by version (Advanced Settings).

Configure Application Properties : Add restart, exclude paths, additional monitoring paths, and cache settings in application.yml or application.properties as shown below.

Restart IDEA : After all changes, restart the IDE to avoid cached configuration issues.

Application Property Examples

spring:
  devtools:
    restart:
      enabled: true   # enable hot reload (default true)
      exclude: "static/**,public/**"   # paths that do not trigger restart
      additional-paths: src/main/java   # extra monitored paths
    livereload:
      enabled: true   # enable browser LiveReload
  freemarker:
    cache: false   # disable template engine cache
spring.devtools.restart.enabled=true
spring.devtools.restart.exclude=static/**,public/**
spring.devtools.restart.additional-paths=src/main/java
spring.freemarker.cache=false
spring.thymeleaf.cache=false

Usage Caveats and Limitations

Effective Scope : Only changes inside method bodies trigger a restart; changes to class signatures, fields, or bean definitions require a full restart.

Session Loss : DevTools restarts the entire application, which clears HTTP sessions.

Production Disable : When the application is packaged (java -jar), DevTools is automatically disabled, but it is safer to mark the dependency as <optional>true</optional>.

Static Resource Optimization : Modifications in /static, /public, or /templates only trigger a browser refresh, not an application restart.

Manual Save Trigger : Although IDEA auto‑saves, you may need to press Ctrl+S or Ctrl+F9 (Build Project) to ensure compilation.

Verification Steps

Run the Spring Boot application in Debug mode .

Modify a controller’s return value and save the file.

Observe the console logs to confirm a fast restart.

Refresh the browser to verify that the changes are reflected.

Alternative Solutions

JRebel : Commercial tool that supports hot swapping of class structure without restart, offering a smoother development experience.

HotSwapAgent : Open‑source solution that leverages JVM HotSwap to achieve limited class‑structure hot replacement.

Conclusion

Spring Boot DevTools is designed as a development‑time tool that provides rapid restarts and static‑resource refreshes, making everyday debugging faster. For more advanced hot‑deployment needs, consider integrating JRebel or container‑based hot‑swap mechanisms.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavamavenSpring Boothot-reloadIntelliJ IDEADevTools
Ray's Galactic Tech
Written by

Ray's Galactic Tech

Practice together, never alone. We cover programming languages, development tools, learning methods, and pitfall notes. We simplify complex topics, guiding you from beginner to advanced. Weekly practical content—let's grow together!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.