SpringBoot实现热部署
第一步:
第二步:
第三步:添加spring-boot-devtools依赖
<!--实现热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
第四步:yml配置
devtools:
livereload:
enabled: true #是否支持livereload
port: 35729
restart:
enabled: true #是否支持热部署
第五步:IDEA配置
(1)在设置中打开自动编译
(2)打开运行时编译
ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running
(3)关闭自动保存-可选
File—>settings—->System Settings—>去掉勾选synchronize files on frame or editor tab activation和去掉勾选save files on frame deactivation
synchronize files on frame or editor tab activation,就是当前应用是intellij时,自动保存文件,比如从浏览器切换到intellij,intellij就是active,会自动保存。 save files on frame deactivation,就是从intellij切换到其他应用时,保存文件。
(3)标志修改文件为星号-可选
File—->Settings—–>Editor—->General—->Editor tabs—->勾选 mark modified files as asterisk
第六步:浏览器安装livereload插件
第七步:测试
(1)修改类 应用会重启
(2)修改配置文件 应用会重启
(3)修改静态文件(html、css等),应用不会重启,但是会调用livereload,浏览器会自动刷新,显示最新的修改内容。