1.引入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency>
2.更改IDEA的配置
在此说明一下,因为IDEA的版本不一样,所有更改的配置也不一样,所有本文章仅仅针对IDEA2021.2版本。
点击File
->settings
->Build,Execution,Deployment
->Compile
路径,找到Build project automatically
并勾选,开启自动生成。
在高级选项中勾选。
3.可通过enabled:false来关闭热部署
spring:
devtools:
restart:
enabled: true # 是否开启热部署工具
4.测试
修改代码后保存,等待5、6秒,项目就自动重启了!