|
@@ -0,0 +1,25 @@
|
|
|
+package com.hz.employmentsite.config;
|
|
|
+
|
|
|
+import com.hz.employmentsite.util.CronUtil;
|
|
|
+import org.quartz.*;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+
|
|
|
+@Configuration
|
|
|
+public class QuartzConfig {
|
|
|
+ private static final String CREDIT_RECORD_TASK_IDENTITY = "Credit_Record_Quartz";
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public JobDetail quartzDetail() {
|
|
|
+ return JobBuilder.newJob(CronUtil.class).withIdentity(CREDIT_RECORD_TASK_IDENTITY).storeDurably().build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Trigger quartzTrigger() {
|
|
|
+ CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.dailyAtHourAndMinute(0, 5); // 每天0点5分执行
|
|
|
+ return TriggerBuilder.newTrigger().forJob(quartzDetail())
|
|
|
+ .withIdentity(CREDIT_RECORD_TASK_IDENTITY)
|
|
|
+ .withSchedule(scheduleBuilder)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+}
|