Say Hello to Developer Tools
Explore how to integrate and utilize Spring Boot Developer Tools to enhance your development experience. Understand features like automatic application restarts, property default toggles, live logging for web activity, and embedded LiveReload support to speed up debugging and testing in your Spring Boot applications.
The Spring Boot team introduced a new module several versions back called Developer Tools, or simply DevTools.
Features of DevTools
This lesson provides multiple features of DevTools:
-
Automatic restart and reload of our application
-
Property defaults
-
Logging changes in autoconfiguration
-
Exclusion of static resources
-
LiveReload support
Adding DevTools to the project
In order to add DevTools to our project, we need to apply the following changes to our pom.xml file:
In Maven, we set it as an optional dependency, so it doesn’t end up in our production code. This is also recommended so that spring-boot-devtools isn’t transitively applied to other code beyond our own.
The spring-boot-devtools module looks at how our application is launched. If it spies things running through java -jar or from a special classloader (such as a cloud provider), then the module will deem it a production application and not use DevTools’ features. Running with Maven’s spring-boot:run signals it to run in development mode with all features enabled.
Automatic restarts and reloads
The Spring Boot team has also added the ability to detect changes in user code and restart our application.
Restart vs. Reload: DevTools loads our code into one classloader and third-party libraries into a separate classloader. When the application is restarted, the ...