一、介绍
Spring Boot 热部署可以在开发调试过程中无需手动重启,就能自动执行编译并生效。
二、开发工具
IntelliJ IDEA、SpringBoot 2.0+
三、操作步骤
1、创建正常SpringBoot的Maven项目
2、在需要热部署的项目中(或者在全局父Maven模块中)加入DevTools
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
3、依次点开菜单 【File】-【Settings】-【Build,Execution,Deployment】-【Compiler】- 勾选右侧的【Build project automatically】
4、按 Shift + Shift ,搜索 registry ,点击 Actions 的 Registry 设置。
找到 compiler.automake.allow.when.app.running 项,并打勾。
5、最后,重启 IDEA.
四、验证
修改 java 代码,无需手动重启,等待几秒钟,查看效果。