idea使用spring boot 熱更新、熱載入
阿新 • • 發佈:2019-02-01
修改程式碼後無需重新make、build、run專案,直接看到結果
兩種方式
第一種:適合Idea自動裝載的Run或Debug
1、Settings->Build project automatically
2、Ctrl+Shift+A ->搜尋registry,找到Registry...,注意是後面有三個點的那個,然後找到compiler.automake.allow.when.app.running,勾選
第二種:這種方式不支援idea自動裝載的run和debug,
Spring boot 提供了devtools,新增依賴,同時在settings裡設定Build project automatically
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> </build>
配置好後使用命令啟動 mvn spring-boot:run
推薦使用第一種方法