1.选中,CTRL + SHIFT + A --> 查找make project automatically
2.CTRL + SHIFT + A --> 查找Registry --> 找到并勾选compiler.automake.allow.when.app.running
3.重启idea
4.在pom.xml中配置依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
5.在pom.xml配置fork属性
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
6.关闭谷歌浏览器缓存
F12(或Ctrl+Shift+J或Ctrl+Shift+I)--> NetWork --> Disable Cache(while DevTools is open)
注意要从IDEA中点击绿色图标运行,并且把terminal终端关闭,不然会显示8080端口被占用。
参考:https://www.cnblogs.com/winner-0715/p/6666579.html