Say Hello to Developer Tools

Get introduced to the features provided by Spring Developer Tools.

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:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
Adding DevTools to our project

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. ...

Get hands-on with 1400+ tech skills courses.