Spring Boot 在IDEA中debug时的hot deployment(热部署)

因为Spring Boot的项目一般会打包成jar发布, 在开发阶段debug时, 不能像传统的web项目那样, 选择exploded resources进行debug, 也没有热更新按钮, 如果每次一点小改动都要重启项目的话, 会造成极大的时间开销. 以下说明如何在IDEA 14.1.1 里面debug  Spring Boot项目时进行热部署(hot deployment). 在开发中不涉及到class meta data变化的改动, 以及静态资源文件改动, 都可以热部署更新.

Spring Boot配置修改

Freemarker的cache要设为false

Debug运行时配置

1. + Application, 选择Main class为项目入口Application; VM Option可以加上-Dfile.encoding=UTF-8, 不加也没问题; Program arguments可以加上 --debug, 也可以不加; Use classpath of module就是默认本模块, 重点是下面的make 任务部分, 添加Run Maven Goal, Command Line输入 clean compile -e, 把这个放到默认的Make前面.

2. 项目启动正常debug后, 修改一些资源文件或java class, 按Build -> Make Module 'xxx', 或者直接 Make Project 就能替换运行时资源. 会弹出提示文件有变化是否需要重新载入, 按确定即可.

不需要勾选Settings->Build, Execution, Deployment->Compiler-> Make project automatically
不需要导入spring-boot-devtools依赖

猜你喜欢

转载自www.cnblogs.com/milton/p/9727185.html
今日推荐