开发过程中使用热部署的好处,就是不用频繁手动的重启项目,提高开发效率。
实现方式有挺多,这里使用的是devtools的工具包,操作简单
配置有三步
- 添加devtools依赖
- 配置springboot
- 配置idea设置
具体详解
1.添加devtools依赖
我使用maven管理的,直接在pom.xml添加即可。gradle管理的自行百度。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
2.配置springboot
在application.properties加上这段
#配置项目热部署
spring.devtools.restart.enabled=true
3.配置idea
需要配置两个地方
(1)顶部菜单File->Setting的Build,Execution,Deployment->Compiler设置中勾选Build project automatically
(2)ctrl + shift + alt + / ,选择Registry,勾选Compiler autoMake allow when app running