第一步: 设置IDEA开启项目自动编译
File => Settings => Build,Execut,Deployment => Compiler 勾中右侧Build Project automatically
第二步: 开启项目运行时自动生成
ctrl + shift + a(windows系统),command+shift+alt+/(mac系统)
搜索命令:registry => 勾选compiler.automake.allow.when.app.running
如下图:
第三步:pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
第四步:开启热部署
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork><!-- 如果没有该配置,热部署的devtools不生效 -->
</configuration>
</plugin>
第五步:重启idea