Spring Boot Developer Tools and Live Reload - Maximize productivity with Hot Swapping


When we develop web applications with Java, we had to restart the server to pick up all changes. This kills productivity. Spring Boot Developers Tools provides solutions to automatically pick up changes without a complete server restart. Lets get productive with Spring Boot Developer Tools.

You will learn

  • How to use Spring Boot Developer Tools?
  • What kind of changes does Spring Boot Developer Tools pick up automatically?
  • How can you use Live Reload to be more productive?

Spring Boot Courses

Image

Image

Image

Image

Image

10 Step Reference Courses

Problem with Server Restarts

When we develop our applications (Web or RESTful API), we would want to be able to test our changes quickly.

Typically, in the Java world, we need to restart the server to pick up the changes.

There are plugins like JRebel which help, but you need shell out $$$ for it.

Restarting server takes about 1 to 5 minutes based on the size of the application. A typical developer does 30 - 40 restarts in a day. I leave it as an exercise to determine how much time a developer can save if the changes are automatically picked up as soon as I make a code change.

Thats where Spring Boot Developer Tools comes into picture.

Adding Spring Boot Developer Tools to Your Project

Adding Spring Boot Developer Tools to your project is very simple.

Add this dependency to your Spring Boot Project pom.xml

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-devtools</artifactId>
	<scope>runtime</scope>
</dependency>

Restart the application.

You are all Set.

Go ahead and make a simple change to your controller. You would see that these changes are automatically picked up.

What kind of changes does Spring Boot Developer Tools pick up?

By default, any entry on the classpath that points to a folder will be monitored for changes.

Here are few important things to note:

These folders will not trigger reload by default

  • /META-INF/maven
  • /META-INF/resources
  • /resources
  • /static
  • /public
  • /templates

You can configure additional folders to scan.

application.properties

spring.devtools.restart.additional-paths = /path-to-folder

You can also configure folders to exclude.

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

Auto refresh your browser with LiveReload

Spring Boot Developer Tools auto loads the changes to application. But if you are developing a web application, you would need to refresh the browser to pickup the change.

LiveReload aims to solve this problem

LiveReload offers extensions for browsers

  • Download from http://livereload.com/extensions/

Once you install the LiveReload plugin for your browser, you would see that the page auto refreshes when you make a change in application code.

LiveReload is Technology in progress!! So, expect a few problems!

Congratulations! You are reading an article from a series of 50+ articles on Spring Boot and Microservices. We also have 20+ projects on our Github repository. For the complete series of 50+ articles and code examples, click here.

Next Steps

Image

Image

Image

Image

Image

Image

Image

Image

Related Posts

Spring Boot Tutorials for Beginners

At in28Minutes, we are creating a number of tutorials with videos, articles & courses on Spring Boot for Beginners and Experienced Developers. This resources will help you learn and gain expertise at Spring Boot.

Spring Boot Basics - What Is A Profile?

When we develop applications, we would want to be able to provide different application configuration in different environments? How do you achieve it with Profiles?

Spring Basics - What Is A Dependency?

Most important feature of Spring Framework is Dependency Injection. To understand Dependency Injection, you need to understand the concept of a Dependency.

Architecture of Spring Framework - Modularity and Spring Modules

One of the most important features of the Spring framework is its modularity. It is not one big monolith framework. What are Spring Modules? How are they organized? What is the architecture of Spring Framework?

What Are Spring Projects?

There are several important Spring Projects solving the needs of enterprises today. What are Spring Projects and how are they different from Spring Modules?

Spring Basics - Introduction To Spring Batch

Spring Batch is a lightweight, comprehensive batch framework that is designed for use in developing robust batch applications.

Spring Framework Basics - What Is Inversion Of Control?

Developers starting with the Spring framework often get confused with terminology - Dependency, Dependency Injection and Inversion Of Control. In this article, we introduce you to the concept of Inversion of Control.

Spring Boot Basics - Introduction To Spring Data and Spring Data JPA

In this article, we take a look at Spring Data and Spring Data JPA.

Spring Basics - Introduction To Spring Framework

In this article, we look to get an introduction to what the Spring framework is, and why it is so widely used.

Spring Boot Basics - Introduction To Spring Data Rest

Spring Data project provides common abstractions to integrate with different kinds of data stores. Spring Data Rest is part of the umbrella of Spring Data projects. It makes it easy to build hypermedia-driven REST web services, on top of Spring Data repositories.