作用
在我們的開發過程中,每次修改代碼就需要將項目重啓,重新部署,對於一些大型應用來說需要花費大量的時間成本。所以可以使用熱部署的方式,來自動重新加載修改過後的文件,一般可以使用 devtools 工具。
POM依賴
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
IDEA配置
修改idea的配置,使其能自動編譯。
(1)File-Settings:
(2)ctrl + shift + alt + / ,選擇Registry:
測試
重啓IDEA,啓動應用後修改文件就會自動刷新。