Spring Scheduled定時任務

使用Spring執行定時器

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

 

只需要引入Spring的context包即可

@Component
//啓動開啓定時任務
@EnableScheduling
public class HbaseFileReload {

    //執行任務週期 cron表達式
    @Scheduled(cron = "0 0/1 * * * ?")
    public void run() {
        System.out.println("test");
    }
}

 

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