网上关于热部署的贴子很多,但是我尝试了很多但是一直不生效,但是呢,后来我看了一个帖子告诉我说修改完代码之后需要rebuild project ,然后我试了一下,好使了。
说一下我的环境
idea 、java8 Spring boot 2.1.1版本
pom依赖
org.springframework.boot
spring-boot-devtools
true
runtime
<build>
<plugins>
<!-- 这是spring boot devtool plugin -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork : 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
然后setting->build->compile->Build Project Automatically
MAC电脑是option+command+shift+/选择Registry 勾中
compiler.automake.allow.when.app.running
最主要的一步是项目重启之后debug模式下rebuild project就可以了,每次rebuild会有一行注释告诉你代码有没有变化