jav*_*977 4 java spring cronexpression spring-scheduled
我的春季服务喜欢
@Scheduled( cron="0 0 7 * * SUN")
public void doSomething() {
// do something
}
Run Code Online (Sandbox Code Playgroud)
我知道你不能拥有为指定一年保留的第7个值.使用表达式我可以告诉spring在特定时间每年运行一次,比如说在2020年12月25日上午6点?
谢谢
是的你可以.看看这个答案吧.简而言之,您可以使用以下格式:
0 0 6 6 9 ? 2010
| | | | | | |
| | | | | | +- 2010 only.
| | | | | +----- any day of the week.
| | | | +------- 9th month (September).
| | | +--------- 6th day of the month.
| | +----------- 6th hour of the day.
| +------------- Top of the hour (minutes = 0).
+--------------- Top of the minute (seconds = 0).
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以通过每月一次,它将仅每年运行一次
@Schedule(cron=""0 0 0 25 12 ?") --- it will run 25th December every year
public void CronExpression(){
//your logic
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7100 次 |
| 最近记录: |