Spring implements scheduled tasks with squertz

preface

Speaking of scheduled tasks, the development partners must be familiar. Some things always need computers to complete, rather than relying on ourselves. However, many people always feel strange to timers. Today, Xiaobian will take his friends to uncover its mystery and explain how spring uses squertz to realize timed tasks.

1、 Required jar

2、 Configuration file

Here, configure when you want to execute your scheduled task and what method you want to execute, as shown in November 2016 10 23:00:00, execute com seewoedu. train. quartz. The generate method of generaterewardlisttask, where cron is used to specify the execution time, and the relevant syntax can be viewed https://www.oudahe.com/p/12420/

3、 Method executed

4、 Problems needing attention

1. When the execution time is specified to the year, there will be a problem, that is, when you start the project after this time, it will always report a memory leak error, which roughly means that your scheduled tasks will never be executed, resulting in the project can not be started all the time.

2. The scheduled task is realized by calculating the time interval from the beginning of your deployment project to the time when you want to execute the scheduled task, rather than obtaining your server time in real time. Therefore, it is not feasible to test whether the scheduled task is effective by modifying the server time.

summary

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>