springboot实现热部署

205 阅读1分钟

1、在pom.xml中添加依赖

        <!--devtools热部署-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <scope>true</scope>
        </dependency>

2、devtools的配置

spring:
  devtools:
    restart:
      enabled: true # 设置开启热部署
      additional-paths: src/main/java # 重启目录

3、IDEA配置

当我们修改了类文件后,idea并不会自动编译,还需要修改idea设置。

  • File->Settings->Build,Execution,Deployment->Compiler->Build Project automatically image.png
  • ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running

image.png image.png