Using scheduled tasks in spring projects
When we want to execute some business methods at a certain point in time, we use timed tasks. It is very simple to use timed tasks in spring projects. as follows
Step 1: add jar package
Step 2: write a task class
Task classes are the same as ordinary Java classes, and task methods are the same as ordinary methods. The operations in task methods are written according to specific needs.
Step 3: add the configuration in the spring configuration file.
The expression format under cronexpression is 7-bit symbols spliced with spaces in the middle, which can be 6 bits. The use case is as follows
Note: I reported a lot of errors when I used it. After searching on the Internet, I basically said that the spring and quartz versions were incompatible. The summary is as follows
Attached error examples and solutions: Reference https://code.google.com/p/wisematches/issues/detail?id=156
spring3. For versions 1.0 and below, use versions below quartz2. OK
spring3. For versions 1.1 and above, the version below quartz2 is OK
This example: using spring 3 1.0 + quartz1. 8.2 OK
Tested: spring 3 1.1+quartz2. 1.0 OK
However, org. Org is required in the above configuration file springframework. scheduling. quartz. Crontriggerfactorybean (the lower version uses crontriggerbean)