一、手工启动
1. 开启开发者工具
<!-- 热部署热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
2. 激活热部署:
Ctrl + F9
3. 关于热部署
重启(Restart):自定义开发代码,包含类、页面、配置文件等,加载位置restart类加载器
重载(ReLoad):jar包,加载位置base类加载器
注意:热部署仅仅加载当前开发者自定义开发的资源,不加载jar资源
二、自动启动
1. 设置自动构建项目
2. Ctrl+Shift+Alt + /
新版本IDEA,这个设置在Settings中的Advanced Settings中,勾选Allow auto-make to...即可。
三、热部署范围配置
默认不触发重启的目录列表:
/META-INF/maven
/META-INF/resources
/resources
/static
/public
/templates
自定义不参与重启排除项
devtools:
restart:
#设置不参与热部署的文件或文件夹
exclude: static/**,public/**,config/application.yml
四、关闭热部署
设置高优先级属性禁用热部署
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled","false");
SpringApplication.run(Springboot12HotDeployApplication.class, args);
}