11

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.

thedoctor
  • 1,498
  • 1
  • 12
  • 12
  • Feel your pain. What I find especially strange is that IntelliJ is able to reload classes (like `@Controllers` - can be easily tested) but not the resources. I did a little debugging test proving that resources are present after app deployment via `getClassLoader().getResource(...)` but no longer available in this way after update resources action. – Jan Zyka Mar 18 '15 at 08:37
  • I'm afraid the Boot support is not an issue here. This is more subtle problem. – Jan Zyka Mar 18 '15 at 09:00
  • For the moment I switch back to making my main application a Spring Boot WAR, and used IntelliJ support for running a WAR with a local tomcat. Using this approach I got my hot deployment back. – thedoctor Mar 18 '15 at 10:18
  • This works as long as you have your resources in the war project. I have separate maven modules (resulting with separate jars) which are dependencies of the war module and some resources are stored in these jars. And replacing such resources doesn't work even when running in external Tomcat/Jetty – Jan Zyka Mar 18 '15 at 12:17
  • I will re-check my setup, my resources are also in additional Jars (the whole application is a single maven project with sub-modules), the WAR project is just a basic shell. It certainly seemed to work OK for me when I changed the resources in the JAR. – thedoctor Mar 18 '15 at 14:20
  • I wonder whether the problem may be using Jetty? In my case `9.2.7`. Will retry with Tomcat 8 and see if there is a difference. Thanks for checking this out! – Jan Zyka Mar 19 '15 at 07:15
  • Seems to be Jetty problem. In Tomcat I'm able to re-deploy the resources just ok – Jan Zyka Mar 19 '15 at 07:37
  • Using Spring Boot together with BroswerSync (as configured in JHipster) and it is a real pleasure. You get auto-reload of your pages. And it works independently of IntelliJ. And there is a lot more going on! I would say well worth the initial cost of setting it up. – Pierre Henry Dec 03 '15 at 15:25

3 Answers3

13

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.

Jan Zyka
  • 17,460
  • 16
  • 70
  • 118
  • I think this solution is the closest thing to Eclipse's functionality. LiveReload started to work as it should. I also highly recommend to assign a shortcut like `ctrl+s` since in idea you don't really need to explicitly save anything anyways. – Jenya G May 19 '16 at 08:11
  • I had to a add 'spring.thymeleaf.cache=false' in my application.properties file to make this work. http://stackoverflow.com/a/38371921/1647845 – Chandra Manthina Oct 24 '16 at 12:18
6

As instructed here adding spring-boot-devtools dependency will enable static resources reloading (templates and css).

Beware that you need to select Build -> Compile for this to work.

sikrip
  • 671
  • 8
  • 10
0
  1. Install jetbrains-ide-support
  2. Start your Spring Boot app
  3. Go in browser and open your_project_page(http://localhost:8080/)
  4. right mouse click(on your page) -> choose "Inspect in IDEA"