Spring Boot: DevTools & Hot Reload
Spring Boot DevTools improves the development experience by automatically restarting the application when files on the classpath change, and triggering a browser refresh via LiveReload. The restart is faster than a cold start because DevTools uses two classloaders: one for stable third-party libraries and one for your application code.
Contents
Adding spring-boot-devtools
Add the snippet below to your project. No further bootstrapping is needed: Spring Boot's auto-configuration picks it up from the classpath.
<!-- Maven — DevTools is automatically excluded from production JARs -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- does not propagate to downstream modules -->
</dependency>
After adding the dependency, run the application from your IDE. DevTools activates automatically when it detects a development environment.
Automatic Restart
DevTools monitors classpath entries. When any file in target/classesbuild/classes
- In IntelliJ IDEA: enable "Build project automatically" (
). Also enable "Allow auto-make to start even if developed application is currently running" in Registry (Settings → Build, Execution, Deployment → Compiler → Build project automatically ).Help → Find Action → Registry - In Eclipse: the project is compiled automatically on every save by default.
- From the terminal: run
and save a file. DevTools detects the change via file system polling../mvnw spring-boot:run
LiveReload Browser Extension
DevTools includes an embedded LiveReload server (port 35729). When the application restarts, it sends a reload signal to connected browsers.
- Install the LiveReload browser extension (Chrome, Firefox, Safari).
- Click the LiveReload icon to connect to
.localhost:35729 - After a code change and restart, the browser refreshes automatically.
# Disable LiveReload if you don't need it
spring.devtools.livereload.enabled=false
Disabling Restart for Specific Paths
Some resources (e.g., static assets, templates, view files) should not trigger a restart
because they do not require the application context to reload.
DevTools already excludes common paths like /META-INF/resources/resources/static/public/templates
# Exclude additional paths — changes to these do NOT trigger restart
spring.devtools.restart.exclude=static/**,public/**,templates/**,custom-dir/**
# Additional paths to WATCH (paths not on classpath)
spring.devtools.restart.additional-paths=src/main/resources
# Turn off restart completely (keep LiveReload)
spring.devtools.restart.enabled=false
You can also trigger restart on demand by touching a trigger file:
# Only restart when this file changes (not on every class change)
spring.devtools.restart.trigger-file=.reloadtrigger
Remote DevTools
Remote DevTools allows you to connect to an application running in a Docker container or remote server and have it restart when you save changes locally. This is useful for developing against a remote environment.
# application.properties on the REMOTE server — enables the remote endpoint
spring.devtools.remote.secret=my-secret-key
// In your IDE run configuration — run this main class pointing at the remote app
org.springframework.boot.devtools.RemoteSpringApplication
// With program argument: http://remote-server:8080
DevTools in Production (Auto-Excluded)
DevTools is automatically disabled and excluded from production JARs by the Spring Boot build plugins. There is no need to conditionally configure it.
- When packaged with
or./mvnw package , DevTools is excluded from the JAR../gradlew bootJar - If you deploy an exploded JAR (e.g., via an application server), DevTools detects that it is not running from a JAR and disables itself.
- DevTools checks for the presence of a fully packaged application and disables itself accordingly.
- If you want to force-disable DevTools in a specific environment: set
in the environment'sspring.devtools.restart.enabled=false or as a system propertyapplication.properties .-Dspring.devtools.restart.enabled=false
<optional>true</optional>