Spring Boot Developer Tools

As spring boot developers, we use a lot of time on things like building the project, restarting the application every time when there is any change made to application files in the local environment. These little things kill the productivity of the developer and it’s really frustrating. Spring boot introduced a solution by introducing the spring boot developer tools feature in spring boot version 1.3+, which addresses these common tasks and makes the developer’s life a lot easier.

In this article, we will learn how to use spring boot dev tools and their advantages for developers.

Table of Contents

Enabling the spring boot developer tools

To enable spring boot developer tools, we have to add the below dependency to our POM file if you are using the maven build.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

If you are using the Gradle build, use the following to the Gradle build file.

dependencies {
    compile("org.springframework.boot:spring-boot-devtools")
}

Following are few of the features of spring devtool

Automatic Restart

Adding the spring boot devtools dependency to build file, enables the automatic restart of the locally running applications. Any changes in the classpath content will restart the locally running server.

This feature is very helpful when we are working on IDE like the eclipse, where any changes in classpath files, like a controller class, automatically triggers the application to restart. This makes the developer’s life a lot easier by saving a lot of time taken to restart the running application manually.

Disable logging of auto configuration changes

Every time automatic restart happens, spring boot logs the changes like add or removal of beans, setting configuration properties, etc. We can disable this by adding the following property.

spring.devtools.restart.log-condition-evaluation-delta=false

Disabling the restart

We can disable the automatic restart by adding the following property to the application.properties file.

spring.devtools.restart.enabled=false

Excluding resources

We can disable automatic application restart on the change of static resource files by adding the following property. The following property disables the automatic restart when any code changes under the /static/ folder.

spring.devtools.restart.exclude=static/**

Live Reload

Spring boot devtools include an embedded live reload the server. This server can be used to trigger browser refresh every time when there is a change in resource files. For this, we have to add browser extension called live reload which is free to use.

This is a very useful feature when you are working with spring boot web application development, where the front end is automatically reloaded in the browser when there is any change in static files or code changes in java source files.

To disable this feature, we can use the following property.

spring.devtools.livereload.enabled = false

Property Defaults

Spring applications use cache support to cache the compiled changes in template files, HTTP header, response, etc. This is useful to improve the performance of the application, but while developing we may end up not seeing the changes done to the application instantly reflecting on the browser.

Spring boot dev tools disable caching by default. This feature helps to save a lot of developers time and improves productivity.


Conclusion

Spring developer tools is a very useful tool, which makes the developer’s life a lot easier and increases the developer’s productivity. Let’s use this wonderful feature and happy coding. 🙂

Spring Boot Developer Tools
Scroll to top

Discover more from ASB Notebook

Subscribe now to keep reading and get access to the full archive.

Continue reading