說在前面
熱加載:文件內容變更服務器自動運行最新代碼。實則在IDEA環境進行熱部署后,下述過程一氣呵成。
1代碼變更,文件自動保存(IDEA自動保存代碼,用戶無需使用COMMAND+SAVE快捷鍵);
2Javadoc重新編譯Java文件生成Class文件;
3Class文件組合生成jar、war包;
4服務器自動運行最新服務包。
-------------------------------------------------------------------------------------------------------------------------
正文 配置
1引入熱加載插件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
2配置Compiler,增加auto build
Preference->Build,Execution,Deployment->Compiler->勾選Build project automatically
注意箭頭處文字,每次新建項目都需要重新勾選Build project automatically
3Preferences->查找並選擇“Registry” ->找到“complier.automake.allow.when.app.running”->勾選此項
PS:
1親測有效,此配置適合IDEA環境的springboot項目,Eclipse配置過程需作改動
2親測有效,前文“代碼變動”包括但不限於.java、.xml、.properties等類型文件,注意pom文件修改不會熱加載
測試環境
IntelliJ IDEA 2018.1.4 (Ultimate Edition)
Build #IU-181.5087.20, built on May 17, 2018
Licensed to Chation
JRE: 1.8.0_152-release-1136-b39 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.12.6
Git Demo Path:https://github.com/MingHaiTian/springboot-start.git