【转】SpringBoot通过配置devtools实现热部署

  1. 1

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

  2. 2

    <dependency>  

                <groupId>org.springframework.boot</groupId>  

                <artifactId>spring-boot-devtools</artifactId>

                <version>1.5.7.RELEASE</version>

                <optional>true</optional>  

    </dependency> 

    【转】SpringBoot通过配置devtools实现热部署
  3. 3

    <plugin>  

                    <groupId>org.springframework.boot</groupId>  

                    <artifactId>spring-boot-maven-plugin</artifactId>  

                    <configuration>  

                        <fork>true</fork>

                        <addResources>true</addResources>  

                    </configuration>  

    </plugin> 

    【转】SpringBoot通过配置devtools实现热部署
  4. 4

    如果使用的是Intellij IEDA开发工具,还需要到设置里将project automatically勾选上;File->Setting->Build,…->Compiler  将右侧project automatically勾上

    【转】SpringBoot通过配置devtools实现热部署
  5. 5

    Intellij IEDA 使用ctrl+shift+a 快捷键搜索Registry,选择搜索出来的第一个

    【转】SpringBoot通过配置devtools实现热部署
  6. 6

    找到compiler.automake.allow.when.app.running,勾上开启此功能即可

    【转】SpringBoot通过配置devtools实现热部署
  7. 7

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

    END

注意事项

  • 两处设置不更改的话,Intellij IEDA可能无法生效