1、新建SpringBoot項(xiàng)目
環(huán)境準(zhǔn)備
- JDK 1.8
- SpringBoot2.2.1
- Maven 3.2+
- 開(kāi)發(fā)工具
- smartGit
- IntelliJ IDEA2018
創(chuàng)建一個(gè)SpringBoot Initialize項(xiàng)目,詳情可以參考我之前博客:SpringBoot系列之快速創(chuàng)建項(xiàng)目教程
在這里插入圖片描述
檢查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>,用于明確表示編譯版本配置有效
在這里插入圖片描述
補(bǔ)充:
如果有加上Thymeleaf模板引擎,需要關(guān)了Thymeleaf緩存,然后按Ctrl+F9重新編譯,修改配置文件:
spring:
thymeleaf:
cache: false
2、IntelliJ IDEA配置
Settings->Build,Execut, Deployment -> Compiler,勾選中左側(cè)的Build Project automatically
在這里插入圖片描述
Ctrl+Alt+Shift+/,選擇Registry

在這里插入圖片描述
勾選complier.automake.allow.when.app.running
在這里插入圖片描述
ok,next需要重啟 IntelliJ IDEA,既可實(shí)現(xiàn)java文件自動(dòng)構(gòu)建,不過(guò)對(duì)于html還是要按Ctrl+F9編譯
代碼例子下載:code download