加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – *和*之间的区别?在Spring @Scheduled(cron =“…”)

发布时间:2020-12-14 16:36:29 所属栏目:Java 来源:网络整理
导读:我一直在查看 Spring Boot示例来安排任务( https://spring.io/guides/gs/scheduling-tasks/)并阅读一些文档( https://javahunter.wordpress.com/2011/05/05/cronscheduler-in-spring/),我看到了*和?几乎互换使用. 例如,行 @Scheduled(cron = "0 15 10 ? * *
我一直在查看 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复制

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读