QuartzConfig.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package cn.cslg.pas.common.config;
  2. import cn.cslg.pas.service.upLoadPatent.PatentToDbTaskJob;
  3. import org.quartz.*;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. /**
  7. * job定义任务(任务描述和任务执行时间)
  8. */
  9. @Configuration
  10. public class QuartzConfig {
  11. @Bean
  12. public JobDetail jobDetail() {
  13. //指定任务描述具体的实现类
  14. return JobBuilder.newJob(PatentToDbTaskJob.class)
  15. // 指定任务的名称
  16. .withIdentity("webUploadJob", "Default")
  17. // 每次任务执行后进行存储
  18. .storeDurably()
  19. .build();
  20. }
  21. @Bean
  22. public Trigger trigger() {
  23. //创建触发器
  24. return TriggerBuilder.newTrigger()
  25. // 绑定工作任务
  26. .forJob(jobDetail())
  27. // 每隔 5 秒执行一次 job
  28. .withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(5))
  29. .withIdentity("webUploadTrigger", "Default")
  30. .build();
  31. }
  32. }