Spring boot hot deployment for templates and resources under IntelliJ

thedoctor picture thedoctor · Jan 13, 2015 · Viewed 12.9k times · Source

Is anyone aware of a mechanism to get hot deployment for resources and template working under IntelliJ 14.0.2 for a Spring Boot application.

I know that full Spring Boot support is scheduled for 14.1 but I have a project that I converted over from a standard WAR project to a Spring Boot project and I really miss the hot deployment.

At the moment I have to manually build the project that the resources are in to get hot deployment and even then it is a bit flaky sometimes. I would prefer to just save a template or a javascript/css file and get it picked up as I did when I was running my app using a local tomcat server via IntelliJ.

I could switch back to Eclipse to get this working, but my project is Scala based and IntelliJ Scala support is far superior.

Answer

Jan Zyka picture Jan Zyka · Mar 19, 2015

So after some testing I came to few conclusions I think someone arriving here may find useful:

If you are running embedded spring boot application from IntelliJ IDEA (myself on 14 at the moment) in debug mode and you want to hot re-deploy resources you can do that via: Run -> Reload changed classes. Setting a keyboard shortcut much recommended.

Don't get fooled by Loaded classes are up to date. Nothing to reload. message. Your static resources have been updated (tested on .js files and Thymeleaf templates).

As pointed out in comments for thymeleaf templates hot-redeploy you would need:

spring.thymeleaf.cache=false

If you are running in external container IntelliJ provides extra features like action on Frame deactivation which is extremely handy for web development. This works fine as well just beware that external Jetty container on 9.2.7 will cause troubles, i.e. unload the resources on Update resources action breaking your webapp. The only fix was app restart for me. Works nicely in Tomcat 8 though.