SpringBoot通过配置devtools实现热部署

SpringBoot通过配置devtools实现热部署

概要:

  基于Maven的SpringBoot项目,通过配置spring-boot-devtools模块来使Spring Boot应用支持热部署,无需每次更改代码都要手动项目,提高开发者的开发效率

步骤:

一、在项目的pom.xml文件添加如下两段

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <optional>true</optional>
</dependency>  
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <fork>true</fork>
        <addResources>true</addResources>
    </configuration>
</plugin
 
  
 
二、设置
1、将project automatically勾选上;File->Setting->Build,…->Compiler  将右侧project automatically勾上

2、Intellij IEDA 使用ctrl+shift+a 快捷键搜索Registry,选择搜索出来的第一个,找到compiler.automake.allow.when.app.running,勾上开启此功能即可

       SpringBoot通过配置devtools实现热部署

此时重新启动项目即可实现热部署,改动任意代码会立即生效,不用再每次重新启动项目

猜你喜欢

转载自www.cnblogs.com/oycyqr/p/9175386.html