首页>代码>spring boot+spring data jpa+h2实现quartz任务管理系统>/spring-boot-quartz-master/src/main/java/com/stackabuse/config/SchedulerConfig.java
package com.stackabuse.config;

import java.util.Properties;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.quartz.QuartzProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

@Configuration
public class SchedulerConfig {

	@Autowired
	private DataSource dataSource;

	@Autowired
	private ApplicationContext applicationContext;

	@Autowired
	private QuartzProperties quartzProperties;

	@Bean
	public SchedulerFactoryBean schedulerFactoryBean() {

		SchedulerJobFactory jobFactory = new SchedulerJobFactory();
		jobFactory.setApplicationContext(applicationContext);

		Properties properties = new Properties();
		properties.putAll(quartzProperties.getProperties());

		SchedulerFactoryBean factory = new SchedulerFactoryBean();
		factory.setOverwriteExistingJobs(true);
		factory.setDataSource(dataSource);
		factory.setQuartzProperties(properties);
		factory.setJobFactory(jobFactory);
		return factory;
	}
}
最近下载更多
yuning1993  LV6 2023年9月19日
sunlzh888888  LV29 2023年4月26日
37207231  LV1 2023年1月13日
最近浏览更多
yimaoermao  LV1 2024年11月28日
TY0165  LV20 2024年6月17日
Gin19960217  LV4 2024年4月15日
zjjhzjb  LV14 2024年3月20日
woldxy  LV12 2024年2月19日
百里守寡  LV5 2024年2月5日
WBelong  LV8 2023年12月27日
yuning1993  LV6 2023年9月19日
zh11332  LV11 2023年9月12日
include  LV8 2023年6月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友