关于热部署

重启(Restart)∶自定义开发代码,包含类、页面、配置文件等,加载位置restart类加载器
重载(ReLoad) : jar包,加载位置base类加载器

Eclipse

添加坐标

1
2
3
4
5
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

重新Build项目

Eclipse中开启了Build Automatically就不用手动再Build了

重新启动项目

完成!

在代码中的改动都会被Spring容器检测到,然后重启服务器。后面就不需要手动重启了!

设置热部署的范围

1
2
3
4
5
spring:
#配置热部署
devtools:
restart:
exclude: #配置哪些文件的改动不进行热部署,如:static/**

禁用热部署

enable属性

1
2
3
4
5
6
spring:
#配置热部署
devtools:
restart:
exclude: #配置哪些文件的改动不进行热部署,如:static/**
enabled: false

!!! info 注意
停用热部署的配置方式有很多种,还可以使用系统属性等等配置方式,不同的配置优先级不同。->官方文档说明<-