63. Hot swapping

63.1 Reload static content

There are several options for hot reloading. 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). The Maven and Gradle plugins also support running from the command line with reloading of static files. You can use that with an external css/js compiler process if you are writing that code with higher level tools.

63.2 Reload Thymeleaf templates without restarting the container

If you are using Thymeleaf, then set spring.thymeleaf.cache to false. See ThymeleafAutoConfiguration for other Thymeleaf customization options.

63.3 Reload FreeMarker templates without restarting the container

If you are using FreeMarker, then set spring.freemarker.cache to false. See FreeMarkerAutoConfiguration for other FreeMarker customization options.

63.4 Reload Groovy templates without restarting the container

If you are using Groovy templates, then set spring.groovy.template.cache to false. See GroovyTemplateAutoConfiguration for other Groovy customization options.

63.5 Reload Velocity templates without restarting the container

If you are using Velocity, then set spring.velocity.cache to false. See VelocityAutoConfiguration for other Velocity customization options.

63.6 Reload Java classes without restarting the container

Modern IDEs (Eclipse, IDEA, etc.) all support hot swapping of bytecode, so if you make a change that doesn’t affect class or method signatures it should reload cleanly with no side effects.

Spring Loaded goes a little further in that it can reload class definitions with changes in the method signatures. With some customization it can force an ApplicationContext to refresh itself (but there is no general mechanism to ensure that would be safe for a running application anyway, so it would only ever be a development time trick probably).