Spring Boot 项目热部署配置
最编程
2024-05-01 11:30:54
...
开发工具:IntelliJ IDEA 2021.3.3
Spring Boot版本:2.6.7
在开发过程中,如果每一次修改代码都要重启项目,实在是一件很浪费时间的事情。好在Spring Boot提供了devtools工具包实现热部署,代码修改后可以自动部署并重新热启动项目。
1. 添加依赖
首先在pom.xml文件中添加devtools依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
默认情况下,/META-INF/maven、/META-INF/resources、/resources、/static、/templates、/public这些文件夹下的文件修改后不会使应用重启,但是会重新加载,devtools内嵌了一个LiveReload server,当资源发生改变时,浏览器刷新。
2. IDEA中配置
我们修改了类文件后,IDEA默认不会自动编译,需要修改IDEA的配置。
(1)File --> Settings --> Build, Execution, Deployment --> Compiler --> Build project automatically,如图所示
(2)File --> Settings --> Advanced Settings --> Allow auto-make to start even if developed application is currently running,如图所示
推荐阅读
-
Spring Boot 的热门部署工具 "和 "Swagger 测试工具
-
spring boot 打包 jar 实现第三方零配置参考
-
springboot 静态资源路径配置和部署项目文件上传路径问题
-
将文件上传到 Spring boot 项目的 Python 请求模块
-
Spring Boot 项目热部署配置
-
nginx如何部署本地项目供异地公众访问?服务器端口映射配置!
-
IDEA 配置 热部署 JRebel(基本开发技巧)
-
kkFileView v4.3.0发布,Spring Boot构建Excel文件在线预览项目方案 - Gitee Newsflash - OSCHINA - 中文开源技术交流社区
-
Jacoco 在 K8S 集群项目中的部署技巧 - 配置过程
-
将 Spring Boot 项目缩减到令人难以置信的 129M->1.3M 的指南!