我一直在查看
Spring Boot示例来安排任务(
https://spring.io/guides/gs/scheduling-tasks/)并阅读一些文档(
https://javahunter.wordpress.com/2011/05/05/cronscheduler-in-spring/),我看到了*和?几乎互换使用.
例如,行
@Scheduled(cron = "0 15 10 ? * *")
和
@Scheduled(cron = "0 15 10 * * ?")
做同样的事情.那么*和?之间有什么区别?
解决方法
asterix代表所有可能的值.问号应用于非特定值
*(“all values”) – used to select all values within a field. For example,“” in the minute field means *”every minute”.
? (“no specific value”) – useful when you need to specify something in
one of the two fields in which the character is allowed,but not the
other. For example,if I want my trigger to fire on a particular day
of the month (say,the 10th),but don’t care what day of the week that
happens to be,I would put “10” in the day-of-month field,and “?” in
the day-of-week field. See the examples below for clarification.
从tutorial复制