依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
加入依赖运行项目后使用CTRL + F9
进行build后就会重新加载服务,原理:项目启动需要经历重启和重载过程,而热部署只进行了重启操作
自动重启
解决每次都需要手动build问题:
- 第一步在IDEA的设置中找到
Build
、Compiler
、勾选Build project automatically
- 第二步使用
ctrl + alt + shift + /
打开Registry
并勾选compiler.automake.allow.when.app.running
在IDEA失去焦点后5秒会自动构建
部署范围配置
关闭热部署
热部署只存在于开发阶段
spring.devtools.restart.enabled=false
IDEA高版本
使用快捷键CTRL + F9
很容易出现热部署失败问题,最好使用自动部署模式
即可自动更新,如果要调整更新的频率,可以Ctrl + Alt + Shift + /
打开选择Registry
搜索compiler.automake.postpone.when.idle.less.than
进行调整