pom.xml
<!--
支持热部署:
1. 修改类–>保存:应用会重启
2. 修改配置文件–>保存:应用会重启
3. 修改页面–>保存:应用不会重启,但会重新加载,页面会刷新
-->
<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>
<!-- 如果没有该配置,devtools不会生效 -->
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
配置idea
“Preferences" -> “Build, Execution, Deployment” -> “Compiler”
☑️"Build project automatically"
"command+alt+shift+/" -> "1.Registry"
"compiler.automake.allow.when.app.running"☑️