开启热部署之后项目可以自动Build和Compile, 在修改代码之后可以立即生效, 不需要重启服务.
- 添加spring-boot-devtools热部署依赖启动器
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
-
IDEA开启自动编译
[File] - [Settings] - [Compiler] 中勾选[自动构建项目]
“Ctrl+Shift+Alt+/” 打开Maintenance, 打开Registry
找到并勾选"compiler.automake.allow.when.app.running"
-
测试: 修改任意代码并保存 ,查看控制台信息会发现项目能够自动编译.说明热部署生效.