接上一篇:https://blog.csdn.net/sinat_22808389/article/details/81590042
在開發過程中,每次修改代碼都要重新啓動服務?好費時間啊,來看看怎麼樣讓springBoot實現熱加載,即不用重啓服務,修改的代碼即時生效。
很簡單,引入依賴如下,便可:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
我們第一次訪問:http://localhost:8080/hello 結果如下:
不關閉服務,我們去改RestController類:
public class RestController {
@RequestMapping("/hello")
public String helloSprinBoot() {
return "hahaha";
}
}
然後再去訪問 http://localhost:8080/hello,結果如下:
在沒有重啓服務的情況下,修改的代碼生效了!至此熱加載配置就完成了!