1. 修改pom.xml
- 在project->dependencies下添加spring-boot-devtools依赖
- 在project->build->plugins下添加spring-boot-maven-plugin插件
具体样例如下:
<project >
...
<dependencies>
...
<!--添加热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!--热部署配置-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--fork:如果没有该项配置,整个devtools不会起作用-->
<fork>true</fork>
</configuration>
</plugin>
...
</plugins>
</build>
</project>
2. 在设置界面中Compiler下,勾选“Build project automatically”
3. 按下快捷键 (Windows: ctrl + shift + alt + /
, Mac: command(⌘)+shift(⇧)+option(⌥)+/
),选择Registry...
,勾上 compiler autoMake allow when app running
4. 重启ide,运行springboot工程.后续修改内容后,就会自动更新了.