spring-boot-devtools热部署

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring-boot-devtools热部署相关的知识,希望对你有一定的参考价值。

springboot提供了热部署,需要添加依赖:

<dependency>
    <groupId> org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional> // 表示该依赖不会传递
</dependency>        

当eclipse类路径下文件触发ctrl + s或者IDEA类文件触发build的时候就会重启

自动触发重启:编译插件需要添加fork = true

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork> // 否则不会触发自动重启
</configuration>
</plugin>

注意:如果IDEA工具设置了自动编译,那么不添加fork也会触发自动重启

设置步骤如下:

1)settings -> compiler -> make project automatically

2)  Shift+Ctrl+Alt+/ -> registry -> compiler.automake.allow.when.app.running -> 勾选







以上是关于spring-boot-devtools热部署的主要内容,如果未能解决你的问题,请参考以下文章

通过spring-boot-devtools在IDEA中实现热部署

maven工程使用spring-boot-devtools进行热部署,更改代码避免重启web容器

spring-boot-devtools 实现热部署

spring-boot-devtools热部署

添加spring-boot-devtools热部署报错

spring-boot-devtools在Idea中热部署方法