The spring.devtools.restart.enabled property switches Spring Boot DevTools automatic restart on or off. It defaults to true, so with spring-boot-devtools on the classpath the application restarts every time a class on the classpath changes. Setting it to false keeps DevTools on the classpath but stops the restart behaviour.
Automatic restart is a development convenience only. It is much faster than a cold start because Spring Boot reloads just the classes you are editing and keeps third-party libraries loaded.
DevTools bundles several features: automatic restart, LiveReload, property defaults for development (such as disabled template caching), and remote support. The spring.devtools.restart.enabled property only controls the restart feature. LiveReload has its own switch, spring.devtools.livereload.enabled.
| Property | Default | Effect |
|---|---|---|
spring.devtools.restart.enabled | true | Restart the application when classpath files change |
spring.devtools.livereload.enabled | true | Run the embedded LiveReload server for browser refresh |
spring.devtools.add-properties | true | Apply development-friendly defaults such as no template caching |
DevTools is a development-time dependency. Mark it optional (Maven) or developmentOnly (Gradle) so it is not transitively exposed.
DevTools is disabled automatically when the application runs as a fully packaged jar (java -jar) or from a special classloader such as a production container. The Spring Boot Maven and Gradle plugins also leave it out of the repackaged archive by default.
Spring Boot DevTools uses two classloaders:
When a file changes, DevTools throws away the restart classloader and creates a new one. The base classloader is untouched, so the JVM does not reload libraries like Hibernate or Jackson. This is why a restart is typically much quicker than stopping and starting the process.
If a library in your own multi-module project should be reloaded too, list it in META-INF/spring-devtools.properties with restart.include.*. Use restart.exclude.* for the opposite.
You can turn off restart in several ways. Pick the one that matches the scope you need.
This disables restart but the restart classloader is still initialised, because the property is read after DevTools has already begun starting up.
To disable restart completely, set the system property before SpringApplication.run:
You can also pass it on the command line: -Dspring.devtools.restart.enabled=false.
DevTools reads spring-boot-devtools.properties from the .config/spring-boot folder of your home directory (or $XDG_CONFIG_HOME/spring-boot). Settings there apply to every Boot application you run on that machine.
Restart is not triggered by every change. By default, changes to resources under /META-INF/maven, /META-INF/resources, /resources, /static, /public and /templates do not restart the application. You can adjust this behaviour.
A trigger file is useful in an IDE that compiles continuously. Without it, the application can restart in the middle of a multi-file edit. With it, you touch one file when you are ready.
ClassCastException errors can appear when the same class is loaded by two loaders. Disable restart if a library needs a single classloader.It is true. Restart is active as soon as spring-boot-devtools is on the classpath and the application is started from an IDE or with mvn spring-boot:run or gradle bootRun.
No. DevTools detects a fully packaged application and disables itself, and the build plugins exclude it from the packaged archive by default. You should still keep it out of production dependencies.
No. Hot swap replaces method bodies inside a running JVM through the debugger. DevTools restart creates a new application context in a new classloader, so it works for any code change, including new classes and annotations.
Set spring.devtools.restart.enabled=false and leave spring.devtools.livereload.enabled at its default. The browser extension will still refresh the page when static resources change.
spring.devtools.restart.enabled is a boolean that defaults to true and controls automatic application restart in Spring Boot DevTools. Restart is fast because only your own classes are reloaded in a throwaway classloader. Disable it with a property, with a system property set before SpringApplication.run for a complete opt-out, or globally in your home-directory DevTools file, and never rely on it in production.