has not been a long time to write something, for a lot of reasons, but the main thing is that they are very lazy and lazy, today finally realize the seriousness of the problem. So that's it. Today's question is also a problem that has just been encountered in the recent years. First of all, say the point.
First, the problem description
When the scheduled task project was published, an error was made. The error message is as follows:
Caused by:java.lang.UnsupportedOperationException:
Support for specifying both a day-of-week and a day-of-month parameter are not implemented.
Second, the problem investigation and localization
First, you navigate to a cron expression in the configuration file in the scheduled task project, which is caused by an error.
The cron expression with the error is as follows:
Cronexpression: "0 1 * * MON-FRI" (a scheduled task that will only be performed every Monday to Friday)
The expression was pointed out by predecessors that the method of "Mon-fri" was not correct, then changed to "2-6" (1 for Sunday, so Monday is 2). However, such changes still have an error.
Then, you can only search for similar error messages on the Internet, and finally find the problem: The fourth item in this expression (left-to-right), that is, the Day-of-month item cannot be *, but should be?.
So the correct cron expression is: "0 50 1?" * Mon-fri "or" 0 50 1? * 2-6 ".
Finally, the error message disappears as soon as the correct modification is made.
Analysis and reflection on the problems of the three
1. The problem arises mainly from the fact that the specific description of the Cron expression is not clear.
So, now we need to study carefully. Considering that there is a good summary of the predecessors, it is reproduced in part of the content of the article (original address: http://www.cnblogs.com/skyblue/p/3296350.html), special here to express our thanks. The specific contents are as follows:
cron expression: From left to right in order to represent the meaning of: * * * * * * * *
format: [seconds] [min] [hour] [day] [month] [week] [year]
Domain |
Value |
Allowed wildcard characters |
Seconds |
0-59 |
, - * / |
Score of |
0-59 |
, - * / |
Hours |
0-23 |
, - * / |
Day (Day-of-month) |
1-31 |
, - * ? /L W C |
Month |
1-12 or Jan-dec |
, - * / |
Week (Day-of-week) |
1-7 or Sun-sat |
, - * ? L |
Year (optional) |
Empty or 1970-2099 |
, - * / |
The wildcard characters are described below:
* represents all values. For example, setting "*" on a divided field means that every minute will trigger.
? Indicates that no value is specified. Use the scene as a value that does not need to be concerned with the current setting of this field. For example: to trigger an action at number 10th per month, but do not care about the weeks, so the field that needs the week position is set to "?", which is set to "0 0 0 10 *?" " 。
- indicates the interval. For example: Set "10-12" on the hour, indicating that the 10,11,12 point will be triggered.
, which indicates that multiple values are specified. For example: Setting "Mon,wed,fri" On the Week field indicates Monday, Wednesday, and Friday triggers.
/ used to increment the trigger. For example, setting "5/15" on the second indicates a 15 second trigger (5,20,35,50) starting from 5 seconds. Set "1/3" on the month field to start with the monthly number 1th, which is triggered every three days.
L denotes the last meaning. For example: Set on the day field to indicate the last day of the month (according to the current month, if it is February, it will be based on whether it is the year of Run [leap]). The week field represents Saturday, which is equivalent to "7" or "SAT". If you precede the "L" with a number, it represents the last of the data. For example, setting the format "6L" On the week field means "last Friday of the month".
W represents the most recent working day from the specified date (Monday to Friday). For example: Set "15W" on the day field, which indicates the most recent business day from month 15th. If the number 15th is exactly Saturday, then find the most recent Friday (14th) trigger, if 15th is the week, then find the nearest next Monday (16th) trigger. If number 15th is on weekdays (Monday to Friday), it will be triggered on that day. If the specified format is "1W", then the nearest working day of the month 1th is triggered. If the number 1th is Saturday, it will be triggered by the number 3rd in Monday. (Note that the "W" can only be set to a specific number before the interval "-") is not allowed.
Little Tips : ' L ' and ' W ' can be used in combination. If "LW" is set on the day field, it is triggered on the last business day of the month (usually referred to as payroll) .
# Ordinal (indicates the number of weeks of the month), for example, setting "6#3" on the week field represents the third Saturday of the month. Note that if you specify "#5", exactly fifth weeks without Saturday, the configuration will not be triggered (for Mother's Day and Father's Day).
Little Tips : the setting of the week field, if the English letter is case-insensitive, Mon is the same as Mon .
2. From the investigation process of the problem, we can see that the location of the problem is actually inaccurate, and there is no analysis of the problem according to the error message. Therefore, the future need to seriously treat the error message, in order to quickly and accurately locate the cause of the problem.
Well, to this time the problem is basically finished. I hope that the same problems in my work will not happen again. Come on!
Starting from the Quartz time setting problem