Using Spring Boot's DevTools for hot code reloading
Developers are always looking for ways to speed things up. Long ago, one of the biggest speedups was incremental compilers and having them run every time we saved a file. Now that it's permeated modern tools, no one thinks twice about such a feature.
Something critically needed when it comes to building Spring Boot apps is the ability to detect a change in our code and relaunch the embedded container.
Thankfully, we just need one addition to our code we built in the previous chapter:
compile("org.springframework.boot:spring-boot-devtools")
Note
If you happen to be using Maven, you would want to include the optional
flag.
So, this tiny module performs the following activities:
- Disables cache settings for autoconfigured components
- When it detects a change in code, it restarts the application, holding onto third-party classes and simply throwing away and reloading custom classes
- Activates an embedded LiveReload (http://livereload.com/) server...