Spring Boot 1.3 would ship with a brand new module called spring-boot-devtools
. The aim of this module was to try and improve the Development-time experience when working on Spring Boot applications.
To use the module you simply need to add it as a dependency in your Maven POM:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency></dependencies>
Or your Gradle build file:
dependencies { compile("org.springframework.boot:spring-boot-devtools")}
Once included, the spring-boot-devtools
module provides a number of nice features so we cover below (If you can ' t is bother to read the Text, skip to the end of the post for a short video).
Property Defaults
If you've used templating technologies such as Thymeleaf with Spring Boot 1.2, you might is familiar with properties such As spring.thymeleaf.cache
. These properties is used to disable caching and allow you to update pages without needing to restart your application. Have support for these properties are pretty handy, but remembering to set them during development have always been a bit of a pain.
Now, if you have spring-boot-devtools
the module, you are no longer need to remember to set the properties. During Development Caching for Thymeleaf, Freemarker, Groovy Templates, Velocity and mustache is all automatically disabl Ed.
Automatic Restart
Used tools such as JRebel or Spring Loaded in the past to provide instant reload for your Java applications. These tools is great, but they does often require additional configuration or IDE plugins to work (and some of them even co St money!)
With Spring Boot 1.3 we ' ve been working on something that's a little slower than these "instant reload" techniques, and in Stead works by restarting your application. When you have spring-boot-devtools
the module included, any classpath file changes would automatically trigger an application restart. We do some tricks-to-try and keep restarts fast, so-many microservice style applications This technique might is good Enough.
Livereload
With sensible ' cache properties ' and ' automatic restarts ' working, needing to manually click the Browser refresh button ea CH Time something changes starts to become a little tedious. So-to-help save your mouse buttons, Spring Boot 1.3 DevTools includes an embedded livereload server. Livereload is a simple protocol this allows your application to automatically trigger a browser refresh whenever things ch Ange. Browser extensions is freely available for Chrome, Firefox and Safari from livereload.com.
Remote Debug Tunneling
If you've ever tried to host a Java application using Docker, or if you've tried a micro PaaS such as Lattice, you may hav E been frustrated about how difficult it can is to debug your code. You need configure Java-to-start with and -Xdebug
somehow forward the appropriate port so that can attach the remote Deb Ugger.
To help with this, Spring Boot 1.3 can tunnel JDWP (the Java Debug wire Protocol) over HTTP directly to your application. This can even work with applications deployed to Internet Cloud providers, that's only expose port and 80
443
(although Since JDWP is quite a chatty protocol this can be quite slow).
Remote Update and Restart
The final trick that DevTools offers are support for remote application updates and restarts. This works by monitoring your local classpath for file changes and pushing them to a remote server which are then restarted . As with the local restarts, you can also the use of this feature in the combination with Livereload.
Video Preview
All the features discussed in this post be already available in Spring Boot 1.3.0.m1 and detailed documentation is Availa BLE in the reference guide. If you're not ready to install the bits yourself yet, here's a short video of shows how they work:
Original link: Click this
DevTools in Spring Boot 1.3