記錄一下我的spring boot 定時任務

1 在 spring boot 的啓動類上 加上 

@EnableScheduling 註解

2 編寫 定時任務類。

@Component
public class ReservationInformationScheduleTask {



    /**
     * 每月1號定時生成下月的預約信息
     */
    @Scheduled(cron = "0 0 0 1 * ?")
    public void testSchedule(){
        System.out.println("this is my test schedule");
    }


}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章