一、引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
二、修改配置文件
- application.properties
#热部署生效
spring.devtools.restart.enabled= true
#设置重启的目录
spring.devtools.restart.additional-paths= src/main/java
#classpath目录下的WEB-INF文件夹内容修改不重启
spring.devtools.restart.exclude= WEB-INF/**
三、开启IDEA的自动编译
- File --> Settings --> Compiler-Build Project automatically
- ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running