Scheduling Task in Spring/Java

前端 未结 5 1550
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 13:07

I am spawning a thread which will keep pulling the chunk of records from database and putting them into the queue. This thread will be started on the server load. I want thi

5条回答
  •  天涯浪人
    2021-01-05 13:54

    @Scheduled(fixedDelay=3600000)
    private void refreshValues() {
       [...]
    }
    

    That runs a task once every hour. It needs to be void and accept no arguments. If you use Spring's Java configuration you'll also need to add the annotation @EnableScheduling to one of your @Configuration classes.

提交回复
热议问题