ScheduleConfig.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.ruoyi.job.config;
  2. import java.util.Properties;
  3. import javax.sql.DataSource;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.scheduling.quartz.SchedulerFactoryBean;
  7. /**
  8. * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
  9. *
  10. * @author ruoyi
  11. */
  12. //@Configuration
  13. //public class ScheduleConfig
  14. //{
  15. // @Bean
  16. // public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
  17. // {
  18. // SchedulerFactoryBean factory = new SchedulerFactoryBean();
  19. // factory.setDataSource(dataSource);
  20. //
  21. // // quartz参数
  22. // Properties prop = new Properties();
  23. // prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
  24. // prop.put("org.quartz.scheduler.instanceId", "AUTO");
  25. // // 线程池配置
  26. // prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
  27. // prop.put("org.quartz.threadPool.threadCount", "20");
  28. // prop.put("org.quartz.threadPool.threadPriority", "5");
  29. // // JobStore配置
  30. // prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
  31. // // 集群配置
  32. // prop.put("org.quartz.jobStore.isClustered", "true");
  33. // prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
  34. // prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
  35. // prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
  36. //
  37. // // sqlserver 启用
  38. // // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
  39. // prop.put("org.quartz.jobStore.misfireThreshold", "12000");
  40. // prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
  41. // factory.setQuartzProperties(prop);
  42. //
  43. // factory.setSchedulerName("RuoyiScheduler");
  44. // // 延时启动
  45. // factory.setStartupDelay(1);
  46. // factory.setApplicationContextSchedulerContextKey("applicationContextKey");
  47. // // 可选,QuartzScheduler
  48. // // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
  49. // factory.setOverwriteExistingJobs(true);
  50. // // 设置自动启动,默认为true
  51. // factory.setAutoStartup(true);
  52. //
  53. // return factory;
  54. // }
  55. //}