天天看點

SpringBoot2.x使用Dev-tool熱部署

什麼是熱部署,使用springboot結合dev-tool工具,快速加載啟動應用

1.核心依賴包:

        <dependency>  

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

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

             <optional>true</optional>  

         </dependency>

    添加依賴後,在ide裡面重新開機應用,後續修改後馬上可以生效

2.    不被熱部署的檔案

         1、/META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates

         2、指定檔案不進行熱部署 spring.devtools.restart.exclude=static/**,public/**

3.手工觸發重新開機 spring.devtools.restart.trigger-file=trigger.txt

             改代碼不重新開機,通過一個文本去控制

在application.properties

spring.devtools.restart.trigger-file=restart.trigger
           

然後在resource目錄下增加了restart.trigger檔案

需要在修改類後,再修改一下restart.trigger才會觸發重新開機。

繼續閱讀