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
IT程序員

浙公網安備 33010602011771號