puzhibing
2022-08-22 1421f8e9c308c4741cb396309035009393b5b036
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.stylefeng.guns.config.quartz;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 
import javax.sql.DataSource;
 
/**
 * @author yxh
 * @date 2021年04月26日 11:18
 */
@Configuration
public class SchedulerConfig implements SchedulerFactoryBeanCustomizer {
    @Autowired
    private DataSource dataSource;
 
    @Override
    public void customize(SchedulerFactoryBean schedulerFactoryBean) {
        // 启动延时
        schedulerFactoryBean.setStartupDelay(10);
        // 自动启动任务调度
        schedulerFactoryBean.setAutoStartup(true);
        // 是否覆盖现有作业定义
        schedulerFactoryBean.setOverwriteExistingJobs(true);
        // 配置数据源
        schedulerFactoryBean.setDataSource(dataSource);
    }
}