一、引入spring-boot-devtools依赖
pom.xml
<dependencies>
<!--...-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
二、IDEA设置
1、【构建、执行、部署/编译器】勾选“自动构建项目和并行编译独立模块”
2、【高级设置】搜索“allow”,勾选“compiler.automake.allow.when.app.running”
三、配置application.properties
application.properties
spring.devtools.restart.enabled=true
spring.devtools.restart.additional-paths=src/main/java
项目编写保存后会自动编译,可能会有几秒的更新时间,属于正常。