devtools热部署

本文介绍了如何在Spring Boot项目中实现热部署,通过引入spring-boot-devtools依赖,配置pom.xml,调整IDEA设置,以及修改全局配置文件,使得在代码修改后无需重启服务器即可生效。详细步骤包括添加依赖、配置编译选项、启用IDEA的自动编译功能以及设置热部署参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

热部署:修改源文件后,不用重启服务器

目录

一:导包

二:修改pom里的配置

三:idea设置

Build,execution,Deployment---Complier---

 ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running

四: 全局配置文件配置

五:效果


一:导包

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional><!--当前这个项目被继承之后,这个不向下传递-->
            <scope>runtime</scope>
        </dependency>

二:修改pom里的<build>配置

三:idea设置

Build,execution,Deployment---Complier---

 ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running

        

四: 全局配置文件配置

#修改即时生效
spring:
  devtools: # 热部署配置
    restart:
     enabled: true  #设置开启热部署
     additional-paths: src/main/java #设置重启的目录,添加目录的文件需要restart
     poll-interval: 3000 #解决项目自动重新编译后接口报404的问题
     quiet-period: 1000
  thymeleaf:
     cache: false    #页面不加载缓存,

五:效果

   修改文件按crlt+f9就行,不需要重启服务器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值