Exemplo n.º 1
0
 @Bean
 public SchedulerFactoryBean schedulerFactoryBean() {
   SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
   scheduler.setTriggers(
       simpleTriggerFactoryBean().getObject(), cronTriggerFactoryBean().getObject());
   return scheduler;
 }
  @Bean
  public SchedulerFactoryBean quartzScheduler() {
    SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean();

    quartzScheduler.setOverwriteExistingJobs(true);

    AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
    jobFactory.setApplicationContext(applicationContext);
    quartzScheduler.setJobFactory(jobFactory);

    Trigger[] triggers = {getCronTrigger().getObject()};

    quartzScheduler.setTriggers(triggers);

    return quartzScheduler;
  }