-
在 Spring Boot 項目的
pom.xml
文件中添加以下依賴:<dependencies> ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> </dependencies>
-
在
application.properties
文件中配置以下屬性:spring.devtools.restart.enabled=true
然后在 IDEA 中按下
Cmd
+Alt
+Shift
+/
,彈出如下窗口,選擇Registry
。
進入如下窗口后,勾選圖中標注的選項,重啟 IDEA。
- 修改項目文件后,按下
Cmd
+F9
,或是點擊圖中所示的按鈕,即可實現熱部署。