懒羊羊
2023-10-10 cd500a4dab1bf530072ff6da83b907eebb48108a
提交 | 用户 | 时间
1ac2bc 1 package cn.stylefeng.guns.config;
2
3 import cn.stylefeng.guns.core.schedue.quartz.StartQuartzExample;
4 import cn.stylefeng.guns.core.schedue.spring.SpringTasks;
5 import org.quartz.Scheduler;
6 import org.springframework.context.annotation.Bean;
7 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
8
9 /**
10  * 定时任务自动配置(需要定时任务的可以放开注释)
11  *
12  * @author fengshuonan
13  * @Date 2019/2/24 16:23
14  */
15 //@Configuration
16 //@EnableScheduling
17 public class SchedulingConfig {
18
19     /**
20      * 定时任务执行测试,注意在Application上加@EnableScheduling
21      *
22      * @author fengshuonan
23      * @Date 2019/3/27 2:48 PM
24      */
25     @Bean
26     public SpringTasks scheduledTasks() {
27         return new SpringTasks();
28     }
29
30     /**
31      * quartz方式,配置Scheduler实例
32      *
33      * @author fengshuonan
34      * @Date 2019/2/24 19:03
35      */
36     @Bean
37     public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) {
38         return schedulerFactoryBean.getScheduler();
39     }
40
41     /**
42      * 启动quartz的示例
43      *
44      * @author fengshuonan
45      * @Date 2019/3/27 3:34 PM
46      */
47     @Bean
48     public StartQuartzExample startQuartzExample() {
49         return new StartQuartzExample();
50     }
51
52 }