天天看點

springboot + idea 代碼修改熱部署/加載

身為JAVA程式員,等待代碼編譯是一件痛苦的事情。況且追求高效是程式員所具有的一種天然品性。

在接觸強大的springboot架構過程中,每次修改代碼後,都要重新啟動。我就想,肯定有方法可以實作代碼修改後熱加載/部署,果不其然,springboot早已為我們準備了解決方案,且友善快捷。收集了一些資料後,親身驗證,以下方法可行,請參照以下方法設定。(本文以idea 為例子)

第一步: 在pom.xml增加下面依賴

[html] view plain copy

  1. <dependency>  
  2.      <groupId>org.springframework.boot</groupId>  
  3.      <artifactId>spring-boot-devtools</artifactId>  
  4. </dependency>  

第二步: 打開idea ,File->Settings-> Build-Execution-Deployment -> Compiler

勾選 Build Project Automatically. 

springboot + idea 代碼修改熱部署/加載

第三步: 按 Shift+Ctrl+A (windows,mac是 command+shift+A) 

将看到彈窗 Enter Action or option name,輸入"registry",輕按兩下第一項"Registry..." ,會彈出另一個視窗,尋找

compiler.automake.allow.when.app.running
           

這一項,并勾選開啟。然後關閉視窗。

springboot + idea 代碼修改熱部署/加載
springboot + idea 代碼修改熱部署/加載

第四步: 重新開機 IDE

繼續閱讀