Spring boot configures scheduled tasks and @ scheduled annotations of scheduled tasks through @ scheduled

Serial timing task

Configuration files need to be added for parallel scheduled tasks

Because the purpose of spring boot is to kill the configuration file, many of what I see on the Internet are realized through the configuration file. Here, it is realized through code configuration:

The online tutorial says that you need to add the @ enableshcheduling annotation on the startup class to find the task annotated @ scheduled and execute it in the background.

Maybe I started the project through the external Tomcat without the startup class, so I can implement the scheduled task without adding this annotation

Let's take a look at the springboot scheduled task @ scheduled annotation

There seem to be a lot of places where timers are needed In the previous project, it is useful to use the timer to cycle the order time, and then change the order status of the timeout

The @ scheduled annotation of springboot can quickly complete the scheduled tasks we need

It should be noted that the timing time of fixedrate and fixeddelay parameters is different If the execution time of the method to be called is long, the difference can be reflected

Fixedrate: execute again after the last execution time point;

Fixeddelay: execute again after the last execution time point;

It is also found that another method is to call the method of the configuration file

summary

The above is what Xiaobian introduced to you. Spring boot configures scheduled tasks through @ scheduled. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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
分享
二维码
< <上一篇
下一篇>>