1.springboot中devtools热部署
1.1 引言
为了进一步提高开发效率,springboot为我们提供了全局项目热部署,日后在开发过程中修改了部分代码以及相关配置文件后,不需要每次重启使修 改生效,在项目中开启了springboot全局热部署之后只需要在修改之后等待几秒即可使修改生效。
1.2 开启热部署
1.2.1 项目中引入依赖
1 <dependency>
2 <groupId>org.springframework.boot</groupId>
3 <artifactId>spring‐boot‐devtools</artifactId>
4 <optional>true</optional>
5 </dependency>
1.2.2IDEA中配置
当我们修改了类文件后,idea不会自动编译,得修改idea设置。
(1)File-Settings-Compiler-Build Project automatically
(2)ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running
1.2.3 启动项目检测热部署是否生效
#1.启动出现如下日志代表生效
1 2019‐07‐17 21:23:17.566 INFO 4496 ‐‐‐ [ restartedMain] com.baizhi.InitApplication : St
arting InitApplication on chenyannandeMacBook‐Pro.local with PID 4496 (/Users/chenyannan/IdeaProjects/i
deacode/springboot_day1/target/classes started by chenyannan in /Users/chenyannan/IdeaProjects/ideacod
e/springboot_day1)
2 2019‐07‐17 21:23:17.567 INFO 4496 ‐‐‐ [ restartedMain] com.baizhi.InitApplication :