一、启动热部署
1.1 开启开发者工具
xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
1.2 激活热部署
Ctrl+F9
1.3 关于热部署
- 重启(Restart):自定义开发代码,包含类、页面、配置文件等,加载位置restart类加载器
- 重载(ReLoad):jar包,加载位置base类加载器
- 热部署仅仅加载当前开发者自定义开发的资源,不加载jar资源
二、自动启动热部署
2.1 设置自动构建项目

ctrl+shift+alt+/


注意:Idea2021版本并没有该选项,具体操作如下:

激活方式:Idea失去焦点5秒后启动热部署
三、热部署范围
- 默认不触发重启的目录列表
- /META-INF/maven
- /META-INF/resources
- /resources
- /static
- /public
- templates
- 自定义不参与重启排除项
yml
spring:
devtools:
restart:
exclude: public/**,static/**