Spring Boot热部署 - 不重启应用也能看到修改效果

引入依赖

在pom.xml引入spring-boot-devtools

1
2
3
4
5
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

加入插件

1
2
3
4
5
6
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>

IDEA设置

进入设置,Build,Execution,Deployment - Compiler,打勾 Build project automatically

Control+Shift+A,搜索Registry,打勾compiler.automake.allow.when.app.running

Run/Debug Configurations

修改Run/Debug Configurations,将On 'Update' actionOn frame deactivation都设成Update classes and resources

这样每次保存,不用重新启动也会应用修改了,修改html是实时的,修改Java会有几秒的延迟