There are several options for hot reloading. The recommended approach is to use
spring-boot-devtools as it provides
additional development-time features such as support for fast application restarts
and LiveReload as well as sensible development-time configuration (e.g. template caching).
Devtools works by monitoring the classpath for changes. This means that static resource
changes must be "built" for the change to take affect. By default, this happens
automatically in Eclipse when you save your changes. In IntelliJ IDEA, Make Project will
trigger the necessary build. Due to the
exclusions, changes to static resources will not trigger a restart of your application.
They will, however, trigger a live reload.
Alternatively, running in an IDE (especially with debugging on) is a good way to do development (all modern IDEs allow reloading of static resources and usually also hot-swapping of Java class changes).
Finally, the Maven and Gradle plugins can
be configured (see the
addResources property) to support running from the command line
with reloading of static files directly from source. You can use that with an external
css/js compiler process if you are writing that code with higher level tools.
Most of the templating technologies supported by Spring Boot include a configuration
option to disable caching (see below for details). If you’re using the
spring-boot-devtools module these properties will be
for you at development time.
If you are using Thymeleaf, then set
for other Thymeleaf customization options.
If you are using FreeMarker, then set
for other FreeMarker customization options.
If you are using Groovy templates, then set
for other Groovy customization options.
spring-boot-devtools module includes support for automatic application restarts.
Whilst not as fast as technologies such as JRebel
it’s usually significantly faster than a “cold start”. You should probably give it a try
before investigating some of the more complex reload options discussed below.
For more details see the Chapter 20, Developer tools section.