在Spring中将bean引用注入到Quartz作业中?
我设法在Spring中使用JobStoreTX持久性存储来配置和调度Quartz作业。我不使用Spring的Quartz作业,因为我需要在运行时动态调度它们,而我发现的所有将Spring与Quartz集成的示例都是在Spring配置文件中对程序进行硬编码的。。。我安排工作: JobDetail emailJob = JobBuilder.newJob(EMailJob.class) .withIdentity("someJobKey", "immediateEmailsGroup") .storeDurably() .build(); SimpleTrigger trigger = (SimpleTrigger) TriggerBuilder.newTrigger() .withIdentity("someTriggerKey", "immediateEmailsGroup") .startAt(fireTime) .build(); // pass initialization parameters into the job emailJob.getJobDataMap().put(NotificationConstants.MESSAGE_PARAMETERS_KEY, messageParameters); emailJob.getJobDataMap().put(NotificationConstants.RECIPIENT_KEY, recipient); if (!scheduler.checkExists(jobKey) && scheduler.getTrigger(triggerKey) != null) { // schedule the job to run Date scheduleTime1 = scheduler.scheduleJob(emailJob, trigger); } EMailJob是一个简单的工作,它使用Spring的JavaMailSenderImpl类发送电子邮件。 public …