<
!-- quartz core --
>
org.quartz-scheduler<
/groupid>
quartz<
/artifactid>
1.8.6
<
/version>
<
/dependency>
<
!-- quartz uses slf4j, so we need an actual logger --
>
ch.qos.logback<
/groupid>
logback-classic<
/artifactid>
1.2.3
<
/version>
<
/dependency>
xmlns:task=""
/spring-task.xsd
之前我們都是通過基於xml的方式實現spring quartz 雖然配置起來特別的方便,但是spring還支援基本註解的方式來配置,這樣做不僅更加簡單,而且**量也更加少了很多。<
task:annotation-driven
/>
<
context:component-scan
base-package
="com"
/>
配置需要排程的類,並新增註解
/**
* 系統中的定時任務
*/@component
//讓spring可以掃瞄到並初始化
public
class
nsfwaction
extends
actionsupport
/**
* 每隔10秒查詢一次是否有訊息
*/@scheduled
(cron =
"0/10 * * * * ?"
)//配置定時任務的執行時間
public
void
queryinfo()
//工作日的周一到周五晚上八點45匯出檔案
@scheduled
(cron =
"0 45 20 ? * mon-fri"
)public string user_exportexcel()
throws ioexception
Spring整合使用quartz
spring已經整合了quartz,在spring中使用quartz的一般步驟為 1.實現任務類 public class productadschedulemanagerimpl 2.在spring xml 配置檔案中配置任務類bean 3.在spring xml 配置檔案中配置methodinv...
Spring框架整合Quartz
首先編寫任務類,該類繼承quartzjobbean父類,並在其實現方法內編寫job任務 配置spring的xml檔案,配置觸發器,以及排程器的bean jobdetail class org.springframework.scheduling.quartz.jobdetailbean name j...
Spring整合Quartz任務排程
最近專案中用到了quartz任務排程來實現定時任務的功能,遂做小結,以便學習交流之用。quartz是乙個開源的作業排程框架,可以用它來建立簡單或者多個複雜的任務,並讓這些任務按計畫執行。我所做的專案是使用了spring中整合的quartz外掛程式,首先說明一下需求背景,這裡要實現的乙個功能是定時將滿...