Spring boot hot deployment for templates and resources under IntelliJ

我是研究僧i 提交于 2019-12-08 15:51:47

问题


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.


回答1:


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.




回答2:


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.




回答3:


  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"


来源:https://stackoverflow.com/questions/27919315/spring-boot-hot-deployment-for-templates-and-resources-under-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!