1、添加maven坐标
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork:如果没有该项配置,整个devtools不会起作用-->
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
2、配置application.yml文件
#数据库
spring:
devtools:
restart:
enabled: true #设置开启热部署
# additional-paths: classpath:cn/lena/weblog/** #重启目录
# exclude: classpath:static/**
freemarker:
cache: false #页面不加载缓存,修改即时生效
3、设置IDEA
IDEA
File>Setting>Build,Execution,Deployment>Compiler
勾选框住的选项后点击apply>ok。
在IDEA界面按“Shift+Ctrl+Alt+/”,会弹出“Maintenance”,然后选择Registry。勾选下图中圈住的key