Hot Reload Spring Boot Apps Without Restart: DevTools, IDEA HotSwap & JRebel
This guide explains how to achieve hot code replacement in Spring Boot projects without restarting the application, covering three approaches—spring-boot-devtools, IntelliJ IDEA's HotSwap plugin, and JRebel—along with configuration steps, demo commands, and practical tips for faster development cycles.
Background
During development, modifying Java code usually requires restarting the Spring Boot application. Small projects restart quickly, but large projects can take 1–2 minutes, slowing development and extending work hours.
The goal is to see code changes instantly without a full restart, which can be achieved through hot deployment techniques.
Method 1: spring-boot-devtools
spring-boot-devtoolsis a Spring Boot developer tool that monitors changes in the classpath and triggers an automatic restart. It does not perform true hot swapping; it uses a fast restart mechanism based on two class loaders: a base loader for unchanged classes (e.g., third‑party jars) and a restart loader for frequently changed classes.
When the application restarts, the restart class loader is discarded and recreated, making the restart much faster than a cold start.
To enable it, add the following dependency to pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>Demo
Run or debug the Spring Boot application.
Open a browser and request http://localhost:8081/HotSwap/01; the response is “No.1”.
Modify the HotSwapController#hotSwap01 method to return “No.2”.
Recompile the project (IDEA: Build → Build Project or shortcut Command + F9 on macOS, Ctrl + F9 on Windows). The application restarts automatically and the endpoint now returns “No.2”.
Enabling “Build project automatically” in IDEA’s Preferences → Compiler allows the compilation to happen when the IDE loses focus, further reducing manual steps.
Method 2: IntelliJ IDEA HotSwap plugin
The HotSwap plugin provides true hot deployment by swapping the changed class bytecode into the running JVM.
Demo
Run or debug the Spring Boot application and access http://localhost:8081/HotSwap/01 (returns “No.1”).
Change the HotSwapController#hotSwap01 method to return “No.2”.
Compile the project manually ( Build → Build Project) or enable “Build project automatically” so that compilation occurs when the IDE loses focus.
After compilation, IDEA shows a “class reloaded” notification, and the endpoint now returns “No.2”.
Method 3: JRebel
Install JRebel from the IDE plugin marketplace and activate it (trial or license). Launch the application with JRebel instead of the standard IDEA run configuration; any code change triggers hot deployment instantly.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
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.
