为什么要使用到热部署?
在开发过程中避免不了修改后台代码,在没有使用热部署之前需要手动重启后台。如果在项目中配置了热部署的话,修改完后台代码只需要稍等片刻就可以生效了
如何在springboot项目中使用到热部署呢?
使用spring-boot-devtools来实现在热部署
首先需要引入jar包依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
其次在application.yml中来配置
spring:
thymeleaf:
cache: false
devtools:
restart:
#设置开启热部署
enabled: true
#重启目录
additional-paths: src/main/java
#页面
exclude: WEB-INF/**
#页面不加载缓存,修改即时生效
freemarker:
cache: false
最后需要在idea中修改配置

修改完配置这个还需要修改
ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running

测试效果
本文介绍在SpringBoot项目中实现热部署的方法,通过使用spring-boot-devtools,避免每次代码修改后的手动重启,提高开发效率。文章详细讲解了依赖引入、配置调整及IDEA设置步骤。


2125

被折叠的 条评论
为什么被折叠?



