spring boot2 (29)-ApplicationRunner和CommandLineRunner初始化

上一篇講了緩存,當訪問緩存時,發現沒有數據就查詢數據庫並寫入緩存。也能夠在項目啓動時就直接查詢並寫入緩存,以避免用戶請求的時候再去查詢,此時就能夠使用ApplicationRunner或者CommandLineRunnerjava CommandLineRunner 用法很簡單,只要實現該接口,啓動項目後會當即使用run方法,args是啓動參數。數據庫 @Component public clas
相關文章
相關標籤/搜索