你是否遇到過這樣的困擾:
當你寫完一段代碼后,要看到效果,必須點擊IDEA的停止按鈕,然后再次重啟啟動項目,你是否覺得這樣很煩呢?
如果你覺得很煩,本文就是用來解決你的問題的。
所謂熱加載,就是讓我們在寫完一段代碼后,不必重啟容器,刷新瀏覽器就能快速看到結果。
在IDEA中需要三個步驟來達到效果:
在build.gradle中加入devtools的依賴
compile("org.springframework.boot:spring-boot-devtools")
在application.properties中禁用模板引擎緩存
使用 FreeMarker
spring.freemarker.cache=false
使用 Thymeleaf
spring.thymeleaf.cache=false
使用 Groovy
spring.groovy.template.cache=false
修改IEDA設置
打開 Settings --> Build-Execution-Deployment --> Compiler,將 Build project automatically.勾上。

點擊 Help --> Find Action..,或使用快捷鍵 Ctrl+Shift+A來打開 Registry...,將 其中的compiler.automake.allow.when.app.running勾上。

全部設置完畢,重啟一下IDEA。
現在你就不必每次都手動的去點停止和啟動了。
參見例子:https://github.com/syler/heroku-lab/tree/hot_swap
本文連接:
http://www.cnblogs.com/asis/p/spring-boot-hot-swap.html
