SpringBoot热部署就是在项目正在运行的时候修改代码, 不需要重新启动项目就可以看到修改后的效果。
一、SpringBoot热部署的流程
1.pom.xml文件中导入 spring-boot-devtools 依赖:
<!--SpringBoot热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
2.在pom.xml中添加插件:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
3.设置application.ym
#配置项目热部署
spring.devtools.restart.enabled: true
4.在idea中设置自动编译:
首先Settings和Other Settings 打开设置(Other Settings 的设置是对整个工作空间项目都启作用,而Settings的设置是对整个项目启作用),搜索Compliler,勾选Build project automatically,如下图所示:
5.按住ctrl + shift + alt + /,出现如下图所示界面,点击Registry,如下图:
6.点击进入后,勾选compiler.automake.allow.when.app.running后关闭即可
到此springboot的热部署就配置成功啦!