1.引入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency>
2.添加插件
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <addResources>true</addResources> </configuration> </plugin> </plugins> </build>
3.yml中开启热部署配置
spring:
devtools:
restart:
enabled: true #开启热部署
4.idea中开启自动编译
勾选Build project automatically配置
File > Settings > build > Compiler > Build project automatically
使用 Ctrl + Shift + Alt + / 调出如下面板,选择Registry
勾选下面这个选项
至此配置完成,启动项目后修改代码后代码也会自动加载,无需手动去重启
热部署会导致类型强制转换的时候报错:https://cloud.tencent.com/developer/article/1497438
安装JRebel并激活
https://blog.csdn.net/lianghecai52171314/article/details/105637251
http://www.yq1012.com/things/5019.html