QuartzConfigurer.java 795 B

1234567891011121314151617181920212223242526
  1. package com.java110.job.myquartz;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.scheduling.quartz.SchedulerFactoryBean;
  6. import javax.sql.DataSource;
  7. @Configuration
  8. public class QuartzConfigurer implements SchedulerFactoryBeanCustomizer {
  9. @Autowired
  10. private DataSource dataSource;
  11. @Override
  12. public void customize(SchedulerFactoryBean schedulerFactoryBean) {
  13. schedulerFactoryBean.setDataSource(dataSource);
  14. schedulerFactoryBean.setStartupDelay(2);
  15. schedulerFactoryBean.setAutoStartup(true);
  16. schedulerFactoryBean.setOverwriteExistingJobs(true);
  17. }
  18. }