1. 程式人生 > 實用技巧 >SpringBoot系列之IDEA專案中設定熱部署教程

SpringBoot系列之IDEA專案中設定熱部署教程

1、新建SpringBoot專案

環境準備

  • JDK 1.8
  • SpringBoot2.2.1
  • Maven 3.2+
  • 開發工具
    • smartGit
    • IntelliJ IDEA2018

建立一個SpringBoot Initialize專案,詳情可以參考我之前部落格:SpringBoot系列之快速建立專案教程

檢查spring-boot-devtools是否加上?

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

ps:修改如下配置,reload才生效,<fork>true</fork>,用於明確表示編譯版本配置有效

補充:
如果有加上Thymeleaf模板引擎,需要關了Thymeleaf快取,然後按Ctrl+F9重新編譯,修改配置檔案:

spring:
  thymeleaf:
    cache: false

2、IntelliJ IDEA配置

Settings->Build,Execut, Deployment -> Compiler,勾選中左側的Build Project automatically

Ctrl+Alt+Shift+/,選擇Registry


勾選complier.automake.allow.when.app.running

ok,next需要重啟 IntelliJ IDEA,既可實現java檔案自動構建,不過對於html還是要按Ctrl+F9編譯

程式碼例子下載:code download