1.引入devtools包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
2.修改plugin
<!--增加-->
<configuration>
<fork>true</fork>
</configuration>
<!--增加之后-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
idea不生效参考网上找到答案
1.勾选compile下的自动编译
2.按下Ctrl+Shift+Alt+/,找到Registry,找到compiler.automake.allow.when.app.running勾选