IntelliJ IDEA使用Spring boot Devtools实现热部署
一、修改IntelliJ IDEA配置
- Settings→Build, Execution, Deployment→Compiler→勾选Build project automatically
- Ctrl+Shift+A→查找Registry→勾选 compiler.automake.allow.when.app.running
- 重启IDEA
二、在项目中引入热部署功能
- 添加Maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
- 启用热部署
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>