|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
package com.letian.modules.job.config; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.scheduling.quartz.SchedulerFactoryBean; |
|
|
|
@ -17,6 +18,9 @@ import java.util.Properties; |
|
|
|
@Configuration |
|
|
|
public class ScheduleConfig { |
|
|
|
|
|
|
|
@Value("${letian.quartz.enabled:true}") |
|
|
|
private boolean quartzEnabled; |
|
|
|
|
|
|
|
@Bean |
|
|
|
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) { |
|
|
|
SchedulerFactoryBean factory = new SchedulerFactoryBean(); |
|
|
|
@ -52,8 +56,8 @@ public class ScheduleConfig { |
|
|
|
factory.setApplicationContextSchedulerContextKey("applicationContextKey"); |
|
|
|
//可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 |
|
|
|
factory.setOverwriteExistingJobs(true); |
|
|
|
//设置自动启动,默认为true |
|
|
|
factory.setAutoStartup(true); |
|
|
|
//设置自动启动,可通过 letian.quartz.enabled 开关控制 |
|
|
|
factory.setAutoStartup(quartzEnabled); |
|
|
|
|
|
|
|
return factory; |
|
|
|
} |
|
|
|
|