分布式定时任务
来源:互联网 发布:高校邦网络课程登录 编辑:程序博客网 时间:2024/06/05 05:07
转载请注明出处 http://www.paraller.com 原文排版地址 点击获取更好阅读体验
```
pom.xml 依赖包
```
配置application.properties
quartz.enabled = truespring.datasource.autoCommit=truespring.datasource.defaultAutoCommit=truespring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.password=mysqlpwdspring.datasource.username=rootspring.datasource.url=jdbc\:mysql\://127.0.0.1\:3306/yea?characterEncoding\=UTF-8
配置数据库 以及 任务信息 crond.properties
spring.datasource.username=rootcron.frequency.SampleJob=0/1 * * * * ?cron.frequency.jobwithcrontrigger=0/1 * * * * ?
配置 quartz.properties 信息
```org.quartz.scheduler.instanceName=spring-boot-quartz-demoorg.quartz.scheduler.instanceId=AUTOorg.quartz.threadPool.threadCount=5org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTXorg.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegateorg.quartz.jobStore.useProperties=trueorg.quartz.jobStore.misfireThreshold=60000 //how late the trigger should be to be considered misfiredorg.quartz.jobStore.tablePrefix=QRTZ_org.quartz.jobStore.isClustered=trueorg.quartz.jobStore.clusterCheckinInterval=20000
```
引入AutowiringSpringBeanJobFactory.java , 自动配置quartz
```public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements ApplicationContextAware {
private transient AutowireCapableBeanFactory beanFactory;@Overridepublic void setApplicationContext(final ApplicationContext context) { beanFactory = context.getAutowireCapableBeanFactory();}@Overrideprotected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception { final Object job = super.createJobInstance(bundle); beanFactory.autowireBean(job); return job;}
}```
SchedulerConfig.java 能够生成触发器
注意 factory.setSchedulerName("schedulerName-项目名称");
```@Configuration@ConditionalOnProperty(name = "quartz.enabled")public class SchedulerConfig {
@AutowiredList
- 分布式定时任务设计
- 分布式定时任务
- 分布式定时任务
- Quartz和分布式定时任务
- 分布式定时任务调度系统
- 分布式定时任务 -- elastic-job
- cronner 分布式定时任务框架
- 分布式开发--分布式定时任务
- 分布式定时任务框架-Elastic Job
- Elastic-Job - 分布式定时任务框架
- Elastic-Job - 分布式定时任务框架
- Elastic-Job - 分布式定时任务框架
- Elastic-Job - 分布式定时任务框架
- Elastic-Job - 分布式定时任务框架
- 分布式定时任务框架-Elastic Job
- Elastic-Job - 分布式定时任务框架
- 定时任务分布式锁的简单实现
- 解决分布式定时任务执行多次问题
- 如何添加自己的应用到openwrt上
- 用户列表完整版
- spring框架(二)——spring概述与spring的核心之IOC
- Java main函数中的String[] args
- ZIP压缩算法详细分析及解压实例解释
- 分布式定时任务
- 数浪最难是起点
- java多线程
- 构造函数与析构函数
- RabbitMq3.6.12 (centos7)安装与基本使用
- 8.PHP 命令行下的世界
- 《坚持,一种可以养成的习惯》读书笔记
- 关于意志力,不得不说的十二件事
- 如何利用番茄工作法提高学习和工作的效率