1.pom引入tools
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
2.配置热部署开关
#热部署生效
spring.devtools.restart.enabled: true
3.关闭模板引擎缓存
freemarker方式:
spring.freemarker.cache=false
thymeleaf方式:
spring.thymeleaf.cache=false
IDEA编辑器需要修改的步骤
IDEA默认是不自动编译的,而spring-boot-devtools又是监测classpath下的文件发生变化才会重启应用,所以需要设置IDEA的自动编译
(1)File-Settings-Compiler-Build Project automatically
idea版本不同,文案也不同。
(2)ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running