這篇文章將為大家詳細(xì)講解有關(guān)quartz中怎么整合spring,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對相關(guān)知識(shí)有一定的了解。
成都創(chuàng)新互聯(lián)公司于2013年開始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站制作、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元龍城做網(wǎng)站,已為上家服務(wù),為龍城各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108
maven依賴:
<dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.0.2</version> </dependency>
Spring配置文件applicationContext-quartz.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- 總管理類 如果將lazy-init='false'那么容器啟動(dòng)就會(huì)執(zhí)行調(diào)度程序 --> <bean name="quartz_scheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="configLocation" value="classpath:quartz.properties" /> <property name="triggers"> <list> <ref bean="updateAccountTrigger" /> <!-- other Trigger --> </list> </property> </bean> <!-- 定義調(diào)用對象和調(diào)用對象的方法 --> <bean id="updateAccountTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="sysTimerServiceImpl" /> <property name="targetMethod" value="updateAllAccounts" /> <property name="concurrent" value="false" /> </bean> <!-- 9-19點(diǎn)每隔一個(gè)小時(shí)觸發(fā) --> <bean id="updateAccountTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail" ref="updateAccountTask" /> <property name="cronExpression" value="0 0 9-19 * * ?" /> </bean> </beans> quartz.properties: #============================================================================ # Configure Main Scheduler Properties #============================================================================ org.quartz.scheduler.instanceName: quartz_scheduler_jobs org.quartz.scheduler.instanceId: AUTO org.quartz.scheduler.skipUpdateCheck: true #============================================================================ # Configure ThreadPool #============================================================================ org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.threadCount: 5 org.quartz.threadPool.threadPriority: 5
定時(shí)任務(wù)的內(nèi)容:
// 調(diào)用對象 @Service("sysTimerServiceImpl") public class SysTimerServiceImpl implements SysTimerService { // 調(diào)用方法 [@Override](https://my.oschina.net/u/1162528) public void updateAllAccounts() { // ... } }
關(guān)于quartz中怎么整合spring就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
名稱欄目:quartz中怎么整合spring
轉(zhuǎn)載來于:http://chinadenli.net/article30/joigso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、網(wǎng)站營銷、外貿(mào)建站、企業(yè)建站、面包屑導(dǎo)航、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)