Spring Boot DevTools
BeginnerProvides automatic application restart on classpath changes, live reload for static resources, and relaxed property defaults during development.
Overview
Spring Boot DevTools (spring-boot-devtools) is a development-time dependency that accelerates the inner loop. Its key feature is automatic restart: it monitors the classpath for changes and restarts only the application classloader while keeping the base classloader (JVM, libraries) alive, making restarts far faster than a cold JVM start. It also enables LiveReload so browsers automatically refresh when static resources change, and it applies a set of developer-friendly property defaults (e.g. disabling template caching, enabling DEBUG logging for web groups). DevTools is automatically disabled when running a packaged jar and is safe to include as a runtime-optional dependency.
Adding DevTools
Add the dependency as optional so it is excluded from production fat-jars. Maven's optional flag and Gradle's developmentOnly configuration both achieve this.
<!-- Maven -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
// Gradle
dependencies {
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}Automatic Restart & Trigger File
By default DevTools watches the classpath. If your IDE compiles on save, restart triggers automatically. For IDEs that compile continuously (IntelliJ with "Build project automatically"), use a trigger file to batch changes and restart only when you explicitly touch it.
# application.properties (development)
spring.devtools.restart.trigger-file=.reloadtrigger
spring.devtools.restart.additional-paths=src/main/resources
spring.devtools.restart.exclude=static/**,public/**
# Disable restart entirely (keep only LiveReload)
spring.devtools.restart.enabled=falseDeveloper-Friendly Property Defaults
DevTools overrides several production defaults to aid development: template caches are disabled (Thymeleaf, FreeMarker), web logging is set to DEBUG, and H2 console is enabled. These are active only when DevTools is on the classpath.
# DevTools auto-applies these defaults — no need to set them manually:
# spring.thymeleaf.cache=false
# spring.freemarker.cache=false
# spring.mvc.log-request-details=true
# spring.h2.console.enabled=true
# logging.level.web=DEBUG
# Remote DevTools (tunnel restart over HTTPS — use carefully):
spring.devtools.remote.secret=mysecretKey Points to Remember
- 1DevTools uses two classloaders: base (libs) + restart (app code) — only restart classloader reloads on change
- 2Declare as optional/developmentOnly so it never ends up in the production fat-jar
- 3LiveReload server starts on port 35729 and integrates with the LiveReload browser extension
- 4Template caches (Thymeleaf, FreeMarker) are disabled automatically — no need to configure
- 5Trigger-file mode prevents spurious restarts in IDEs that save files aggressively
- 6Remote DevTools allows restarting a remote app via a secure tunnel — use only in controlled staging environments
Interview Questions
Sign in to ask AriaHow does DevTools achieve faster restart compared to a full JVM restart?
Why should spring-boot-devtools be declared as optional/developmentOnly?
What is a trigger file and when would you use one?
Which property caches does DevTools disable automatically?
How do you disable only automatic restart while keeping LiveReload active?
Ask Aria about Spring Boot DevTools
Your personal AI tutor — ask anything about this concept
Revision Status
Personal Notes
Sign in to save personal notes for this topic.
Discussion
Sign in to join the discussion.