spring-boot-devtools进行热部署
2020-05-09 本文已影响0人
马铃薯a
spring-boot-devtools是一个为开发者服务的模块,其中最重要的功能就是自动实现把更新的应用代码更改到最新的APP上;
其工作原理是在发现代码有更改之后,自动重新启动应用,但是速度比手动停止后再启动要更快。
spring-boot-devtools依赖配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>true</scope>
</dependency>
注意,还需要加入spring-boot-maven-plugin
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--如果没有该项配置,devtools不会起作用,即应用不会restart -->
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
spring-boot-devtools还可以实现页面热部署(即页面修改后会立即生效,这个可以通过直接在application.properties文件中配置spring.thymeleaf.cache=false来实现(注意,不同的模板配置不一样)