Hot-Reload Java Code Without Restart: Compare Spring Boot DevTools, IDEA HotSwap, and JRebel
This guide explains why hot‑reloading Java code is essential for large Spring Boot projects, compares three approaches—Spring Boot DevTools, IntelliJ IDEA's built‑in HotSwap, and the JRebel plugin—and provides step‑by‑step installation and usage instructions for each method.
Hot‑Reloading Options for Spring Boot Development
When a Spring Boot application grows, a full restart after each code change can take 1–2 minutes, slowing development. Hot‑reloading lets you apply changes without restarting the JVM.
1. Spring Boot DevTools (not recommended)
Spring Boot DevTools watches the classpath and triggers an automatic restart when compiled classes change. The restart creates a new classloader, which is slower than true hot‑swap, so it is generally unsuitable for fast feedback loops.
2. IntelliJ IDEA HotSwap (Ultimate edition)
IntelliJ IDEA Ultimate provides a built‑in HotSwap that works during a debugging session. It replaces the bytecode of already loaded classes.
2.1 How to use
Set the Spring Boot main class as the entry point and enable “HotSwap” in the Run/Debug configuration.
Start the application in Debug mode.
After editing Java source, click the Hot Reload button (lower‑left corner) or press Ctrl+F9 to compile and reload the class.
2.2 Limitations
Only additions of methods or fields are supported; deletions are ignored.
Visibility can be increased but not decreased.
Method signatures must remain unchanged; only the method body can be swapped.
Changes that affect class hierarchy (e.g., adding interfaces, changing super‑class) are not applied.
3. JRebel Plugin (highly recommended)
JRebel provides full‑stack hot‑loading for Spring Boot, supporting additions, removals, and modifications of methods, fields, and class structures without restarting the JVM. It works with both IntelliJ IDEA Ultimate and Community editions.
3.1 Installation
Download JRebel version 2022.4.1 from
https://plugins.jetbrains.com/plugin/4441-jrebel-and-xrebel/versions.
In IntelliJ, open Preferences → Plugins and choose “Install Plugin from Disk…”, then select the downloaded ZIP file.
Restart IntelliJ to activate the plugin.
Open Preferences → JRebel & XRebel , paste the activation GUID
https://jrebel.qekang.com/1e67ec1b-122f-4708-87d0-c1995dc0cdaa, provide any email, and click “Activate”.
Enable “Work Offline” to keep the license active when the network is unavailable.
3.2 Using JRebel
Click the “Debug With JRebel” button to launch the application with JRebel enabled.
After each code change, click the lower‑left “Hot Reload” button (or press Ctrl+F9) to apply modifications instantly.
JRebel supports adding, removing, and changing methods, fields, and class hierarchies, as well as updating Spring configuration files, resources, and static assets without a JVM restart.
Java Architect Handbook
Focused on Java interview questions and practical article sharing, covering algorithms, databases, Spring Boot, microservices, high concurrency, JVM, Docker containers, and ELK-related knowledge. Looking forward to progressing together with you.
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.
