刚开始使用springboot的时候发现每次有代码修改都需要重启,真的不要太麻烦!!!!!
决心研究下如何热部署!
个人能力有限,暂时仅了解两种方式,写出来与大家分享!
本章分享第一种方法!idea+springboot+freemarker热部署(我用的是freemarker)
第一步:在maven中加入devtools的依赖(这里我使用的是maven来管理项目)
注意:此处我将 fork 设置成true之后,无法debug!
第二步:在application.properties中设置禁用模板引擎缓存
spring.freemarker.cache=false
spring.freemarker.settings.template_update_delay=0
第三步:修改IDEA的设置
- 打开 Settings –> Build-Execution-Deployment –> Compiler,将 Build project automatically.勾上。
- 点击 Help –> Find Action..,或使用快捷键 Ctrl+Shift+A来打开 Registry…,将其中的compiler.automake.allow.when.app.running勾上。
全部设置完毕,重启一下IDEA。现在你就不必每次都手动的去点停止和启动了。