IDEA中Spring Boot實現熱部署
阿新 • • 發佈:2018-12-14
IntelliJ IDEA 作為當下較為熱門的Java IDE,當使用Spring Boot進行開發時,由於靜態頁面經常修改,每次重啟十分麻煩。因此實現Spring Boot熱部署尤為重要。
Devtools
Spring為開發者提供了spring-boot-devtools模組進行Spring Boot熱部署,提高了開發效率,無需手動重啟應用。使用需要在pom.xml
新增如下配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</ artifactId>
<optional>true</optional>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources >true</addResources>
</configuration>
</plugin>
在application.yml中新增配置
thymeleaf:
cache: false # 關閉cache,重新整理即可顯示新頁面
devtools: restart:
enabled: true # 啟用熱部署
additional-paths: src/main/resources # 設定重啟目錄
IDEA設定
(1)File->Settings->Compiler->Build project automatically,將其打勾。
(2)ctrl+shift+A,在檢索框輸入Registry,隨後找到Compiler autoMake allow when app running