admin
2024-01-08 22f70cc8b2ba603e82bba058db320dced48f9470
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cn.stylefeng.guns.config;
 
import cn.stylefeng.guns.core.schedue.quartz.StartQuartzExample;
import cn.stylefeng.guns.core.schedue.spring.SpringTasks;
import org.quartz.Scheduler;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 
/**
 * 定时任务自动配置(需要定时任务的可以放开注释)
 *
 * @author fengshuonan
 * @Date 2019/2/24 16:23
 */
//@Configuration
//@EnableScheduling
public class SchedulingConfig {
 
    /**
     * 定时任务执行测试,注意在Application上加@EnableScheduling
     *
     * @author fengshuonan
     * @Date 2019/3/27 2:48 PM
     */
    @Bean
    public SpringTasks scheduledTasks() {
        return new SpringTasks();
    }
 
    /**
     * quartz方式,配置Scheduler实例
     *
     * @author fengshuonan
     * @Date 2019/2/24 19:03
     */
    @Bean
    public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) {
        return schedulerFactoryBean.getScheduler();
    }
 
    /**
     * 启动quartz的示例
     *
     * @author fengshuonan
     * @Date 2019/3/27 3:34 PM
     */
    @Bean
    public StartQuartzExample startQuartzExample() {
        return new StartQuartzExample();
    }
 
}