1. 工程中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<version>2.2.2.RELEASE</version>
<optional>true</optional>
</dependency>
2. pom.xml中添加插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 没有该配置,devtools 不生效 -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
3. 在IDEA设置中开启自动编译的权限

4. 热注册开启

5. 重启
原文:https://www.cnblogs.com/xiluhua/p/14129647.html