熱部署可以使的修改代碼後,無須重啓服務器,就可以加載更改的代碼。
具體步驟
一、開啓IDEA的自動編譯(靜態編譯)
操作步驟:打開頂部工具欄 File -> Settings -> Default Settings -> Build -> Compiler 然後勾選 Build project automatically 。
二、開啓IDEA的自動編譯(動態編譯)
操作步驟:同時按住 Ctrl + Shift + Alt + / 然後進入Registry ,勾選自動編譯並調整延時參數。
- compiler.automake.allow.when.app.running -> 自動編譯
- compile.document.save.trigger.delay -> 自動更新文件
三、開啓IDEA的熱部署策略
操作步驟:頂部菜單- >Edit Configurations->SpringBoot插件->目標項目->勾選熱更新。
四、在項目添加熱部署插件
操作步驟:在maven項目中的pom.xml中引入以下依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
五、關閉瀏覽器緩存
操作步驟:以Goole瀏覽器爲例,打開F12的Network選項欄,然後勾選【✅】Disable cache 。