# SpringBoot3教程 - 9 热部署
什么是热部署?
热部署就是不用每次修改代码后都要重新启动项目,开启热部署后,修改保存之后,几秒之后就可生效。
下面说一下 SpringBoot 热部署的配置。
# 9.1 引入依赖
在项目 pom.xml 文件中引入 Maven 依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
1
2
3
4
5
6
2
3
4
5
6
# 9.2 配置IDEA
打开 IDEA 配置 -> Build, Execution, Deployment -> Compiler -> 勾选 Build project automatically
。
保存。
然后
新版本的 IDEA 找到 Advanced Settings
-> 勾选 Allow auto-make to start even if developed application is currently running
。
旧版本的 IDEA 按住 ctrl + shift + alt + /
(Mac系统为 command + shift + alt + /
),打开对话框:
选择 Registry
,然后勾选 compiler.automake.allow.when.app.running
。
# 9.3 修改代码
修改代码保存后,项目会重新加载,查看控制台,项目会重新加载。