1.导入spring-boot-devtools包
<!--devtools 热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
2.添加Maven 插件并设置fork
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork : 如果没有该项配置,热部署devtools不会起作用,即应用不会restart -->
<fork>true</fork>
</configuration>
</plugin>
3.Application.properties 进行devtools热部署配置
#devtools热部署
#开启热部署
spring.devtools.restart.enabled=true
#指定修改后触发热部署的内容path,默认是全部内容,可以不进行指定
# spring.devtools.restart.additional-paths=com.springboot.websocket.*
#关闭模板引擎的缓存
spring.thymeleaf.cache=false
4.开启IDEA自动编译

自动编译
5.ctrl+shift+alt+/ 进入Registry勾选上compiler.automake.allow.when.app.running

ctrl+shift+alt+/.png

compiler.automake.allow.when.app.running
网友评论