Spring Quartz:我不明白为什么这个cron表达式每隔一小时触发两次?

  • 我想每小时一次,每天12点触发触发,
  • 我尝试每小时跟踪一次代码,但每小时两次触发两次

我的控制器类别为:

private Trigger buildJobTrigger(JobDetail job,ZonedDateTime startAt) {
        return TriggerBuilder.newTrigger()
                .forJob(job)
                .withIdentity(job.getKey().getName(),"hourly update-triggers")
                .withDescription("Send updated hour trigger")
                .startAt(Date.from(startAt.toInstant()))
                .withSchedule(CronScheduleBuilder.cronSchedule("0 0 * ? * * "))
                .build();
              //  .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                //      .withIntervalInHours(1))

                  //  .repeatForever()
                   // .withMisfireHandlingInstructionNextWithExistingCount())
               // .build();
            //   .withSchedule(CronScheduleBuilder.cronSchedule("0 0 0/1 * * ?"))

    }

我的组件类是:

protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
            System.out.println("Executing Job with key {}"+ jobExecutionContext.getJobDetail().getKey());

                System.out.println("--------------------------------------------------------------------");
                System.out.println("MyJob start: " + jobExecutionContext.getFireTime());
                JobDetail jobDetail = jobExecutionContext.getJobDetail();
                System.out.println("Example name is: " + jobDetail.getJobdataMap().getString("example"));       
                System.out.println("MyJob end: " + jobExecutionContext.getJobRunTime() + ",key: " + jobDetail.getKey());
                System.out.println("MyJob next scheduled time: " + jobExecutionContext.getNextFireTime());
                System.out.println("--------------------------------------------------------------------");



        }

我正在输出:

MyJob start: Wed Nov 27 19:00:00 IST 2019
Example name is: null
MyJob end: -1,key: 1456.93.d6216687-c2c1-4503-87ac-3f2160ccf393
MyJob next scheduled time: Wed Nov 27 20:00:00 IST 2019
--------------------------------------------------------------------
Executing Job with key {}1456.93.de9dcbf8-3894-4d13-b5a0-5527e70865f6

--------------------------------------------------------------------
MyJob start: Wed Nov 27 19:00:03 IST 2019
Example name is: null
MyJob end: -1,key: 1456.93.de9dcbf8-3894-4d13-b5a0-5527e70865f6
MyJob next scheduled time: Wed Nov 27 20:00:00 IST 2019
---------------------------------------------------------------

- Database entry image

cen12 回答:Spring Quartz:我不明白为什么这个cron表达式每隔一小时触发两次?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3021099.html

大家都在问