Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Spring Boot 2.x整合Quartz

Exrick edited this page Jan 13, 2019 · 5 revisions

Spring Boot 2.x整合Quartz

  • 官方文档
  • 导入依赖
    <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-quartz</artifactId>
    </dependency>
  • 由于定时任务的信息默认保存在内存,当应用重启后,定时任务信息将会丢失。因此可以使用数据库存储定时任务信息,当系统重启后仍保留定时任务信息,继续执行之前设置的定时任务。Spring中配置如下:
    spring:
     quartz:
     # 任务信息存储至数据库
     job-store-type: jdbc
  • 初始化quartz数据库表,xboot.sql中已包含,其他数据库可以到官网下载,Spring Booot 2.x已集成最新v2.3版本,下载解压后路径在 quartz-2.2.3-distribution\quartz-2.2.3\docs\dbTables
  • 其他相关配置
    spring:
     quartz:
     #相关属性配置
     properties:
     org:
     quartz:
     scheduler:
     instanceName: clusteredScheduler
     instanceId: AUTO
     jobStore:
     class: org.quartz.impl.jdbcjobstore.JobStoreTX
     driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
     tablePrefix: QRTZ_
     isClustered: true
     clusterCheckinInterval: 10000
     useProperties: false
     threadPool:
     class: org.quartz.simpl.SimpleThreadPool
     threadCount: 10
     threadPriority: 5
     threadsInheritContextClassLoaderOfInitializingThread: true

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /