1、导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
2、配置plugin
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
3、设置Settings,开启自动编译
4、设置允许自动编译
ctrl + shift + alt + /, 选择Registry, 勾选 Compiler autoMake allow when app running
备注:最后可能要重启一下IDEA
因为热部署会消耗过多的系统资源,所以不建议这样使用,可以采取另外一种方法
第一步与第二步同上述前面的两个步骤
3、Edit Configuration, 选择 Update classes and resources,如下图
这样就可以在运行的时候点击下图圆框所示的内容更新