QuartzConfigurer.java 840 B

123456789101112131415161718192021222324252627
  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.core.io.Resource;
  6. import org.springframework.scheduling.quartz.SchedulerFactoryBean;
  7. import javax.sql.DataSource;
  8. @Configuration
  9. public class QuartzConfigurer implements SchedulerFactoryBeanCustomizer {
  10. @Autowired
  11. private DataSource dataSource;
  12. @Override
  13. public void customize(SchedulerFactoryBean schedulerFactoryBean) {
  14. schedulerFactoryBean.setDataSource(dataSource);
  15. schedulerFactoryBean.setStartupDelay(2);
  16. schedulerFactoryBean.setAutoStartup(true);
  17. schedulerFactoryBean.setOverwriteExistingJobs(true);
  18. }
  19. }