Quartz | Spring Boot整合Quartz
2018-07-25 本文已影响120人
冯文议
引言
依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
</dependencies>
配置
可在application.yml 或者 application.properties中:
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
#数据库方式
#job-store-type: jdbc
#初始化表结构
#jdbc:
#initialize-schema: never
controller
@Autowired
private Scheduler scheduler;