1、pom.xml文件添加devtools依赖包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<!-- 依赖不会传递,其他项目想要使用devtools, 需要重新引入 -->
<optional>true</optional>
</dependency>
2、application.properties 文件配置
#热部署
#thymeleaf不缓存,即时刷新,页面修改后会立即生效
spring.thymeleaf.cache=false
#开启devtools
spring.devtools.restart.enabled=true
#监听目录
spring.devtools.restart.additional-paths=src/main/java

本文介绍如何在Spring Boot项目中配置热部署,通过添加devtools依赖并设置相关属性,实现代码修改后的自动重启,提高开发效率。
1448

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



