Spring Boot DevTools — Hot Reload and Live Restart in Development
Fast recall
Quick revision
Core answer
true or Gradle developmentOnly) to guarantee it never reaches production. Remote DevTools is a security risk — never enable on hosts reachable from untrusted networks.Whether the candidate understands the restart mechanism and why DevTools is development-only
Including `spring-boot-devtools` as a regular dependency instead of marking it as `developmentOnly`/`optional`, risking production inclusion
Explain the two-classloader restart mechanism, why it's faster than a cold restart, the IDE auto-build requirement, and the security risk of remote DevTools
Interview-ready guide
Interview answer
Spring Boot DevTools speeds up the inner development loop — the cycle of make a change, rebuild, see the result. Its core trick is restarting only the application classes, not the entire JVM.
The two-classloader restart
- Classloader 1 (base): loads libraries, Spring Boot jars, everything that does not change — created once and never reloaded
- Classloader 2 (restart): loads only your application classes — discarded and recreated on each code change
- Result: a restart that takes 1-2 seconds instead of 15-30 seconds for a full JVM restart
Restart vs LiveReload
- Code changes (
.javafiles) trigger a restart of the application classloader - Static resources, templates, and property files trigger a LiveReload signal to the browser — page refreshes without a JVM restart
Keeping devtools out of production
- Mark as
in Maven — the Spring Boot repackager excludes optional dependenciestrue - Gradle:
developmentOnly 'org.springframework.boot:spring-boot-devtools' - Devtools also auto-disables itself when running from a packaged JAR via
java -jar— but optional marking is the belt-and-suspenders approach
Remote DevTools — caution
- Enables remote class reload via a signed payload — effectively remote code execution
- Never enable on internet-facing hosts; never reuse the secret across environments
IDE requirement
- DevTools needs IntelliJ 'Build Automatically' or Eclipse 'Build Automatically' enabled
- Without it, the watched directories never change and restart appears broken
Spring Boot DevTools also disables HTTP caching headers during development (so you always see the latest response) and enables the H2 web console when H2 is on the classpath. In an interview, the strong answer is: two-classloader restart for speed, optional dependency scope to stay out of production, IDE auto-build requirement, and remote DevTools as a known security risk.
Spring Boot DevTools — Hot Reload and Live Restart in Development
Direct Answer
Spring Boot DevTools provides automatic restart on code changes, LiveReload browser integration, and relaxed caching for development. It uses two classloaders — a base classloader for dependencies (unchanged) and a restart classloader for application code (reloaded on change) — making restart 2-5x faster than a cold start. DevTools is automatically disabled when running from a packaged JAR, but should be marked as a development-only dependency (Maven <optional>true</optional> or Gradle developmentOnly) to guarantee it never reaches production. Remote DevTools is a security risk — never enable on hosts reachable from untrusted networks.
Common Mistakes & Pitfalls
Including spring-boot-devtools as a regular dependency instead of marking it as developmentOnly/optional, risking production inclusion
Check your understanding
Answer these without looking back at the article.
- Why is the two-classloader restart mechanism faster than a cold JVM start?
- What is the security risk of remote DevTools and when (if ever) is it acceptable to enable it?
- How do you keep `spring-boot-devtools` out of the production JAR?
- Why might DevTools 'not work' even when configured correctly, and how do you fix it?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.