- 宣傳官網(wǎng) http://xb.exrick.cn
- 在線Demo http://xboot.exrick.cn
- 開(kāi)源版Github地址 https://github.com/Exrick/x-boot
- 開(kāi)發(fā)文檔 https://www.kancloud.cn/exrick/xboot/1009234
- 獲取完整版 http://xpay.exrick.cn/pay?xboot
在這里插入圖片描述
Spring Boot 2.x整合Quartz
- 官方文檔
- 導(dǎo)入依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-quartz</artifactId> </dependency>
- 由于定時(shí)任務(wù)的信息默認(rèn)保存在內(nèi)存,當(dāng)應(yīng)用重啟后,定時(shí)任務(wù)信息將會(huì)丟失赦肃。因此可以使用數(shù)據(jù)庫(kù)存儲(chǔ)定時(shí)任務(wù)信息亲配,當(dāng)系統(tǒng)重啟后仍保留定時(shí)任務(wù)信息队橙,繼續(xù)執(zhí)行之前設(shè)置的定時(shí)任務(wù)。Spring中配置如下:
spring: quartz: # 任務(wù)信息存儲(chǔ)至數(shù)據(jù)庫(kù) job-store-type: jdbc
- 初始化quartz數(shù)據(jù)庫(kù)表,xboot.sql中已包含履澳,其他數(shù)據(jù)庫(kù)可以到官網(wǎng)下載竖哩,Spring Booot 2.x已集成最新v2.3版本哭廉,下載解壓后路徑在
quartz-2.2.3-distribution\quartz-2.2.3\docs\dbTables
- 其他相關(guān)配置
spring: quartz: #相關(guān)屬性配置 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