1、修改pom文件,增加配置
-
<dependency>
-
<groupId>org.springframework.boot
</groupId>
-
<artifactId>spring-boot-devtools
</artifactId>
-
<optional>true
</optional>
<!-- 这个需要为 true 热部署才有效 -->
-
</dependency>
-
<build>
-
<plugins>
-
<plugin>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-maven-plugin</artifactId>
-
<configuration>
-
<!--该配置必须-->
-
<fork>
true</fork>
-
</configuration>
-
</plugin>
-
</plugins>
-
</build>
2、修改 设置里的 【File | Settings | Build, Execution, Deployment | Compiler】,勾选 【buid- project automatically】
3、搜索【Registry】,选择最下面的 Action 【Registry】,并双击打开
找到【compiler.automake.allow.when.app.running】,并勾选如下图
4、菜单【Run>Edit Configurations>Configuration>Spring Boot】,修改【On update action】等选项的值为【Upate classes and resources】,点击【Apply】,完成全部设置
5、修改代码 ,热部署即可生效~
参考博文: