<!-- quartz定时任务 --> <!-- ****************************************配置跑批**************************************--> <!-- 线程执行器配置,用于任务注册 --> <bean id="executor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <property name="corePoolSize" value="10" /> <property name="maxPoolSize" value="100" /> <property name="queueCapacity" value="500" /> </bean> <!-- ============= 业务对象============= 将需要添加定时任务调度的类配置到这里 --> <!-- <bean id="articleBatchRun" class="com.cloudshield.hongce2.utils.WebsiteMonitoring" /> --> <bean id="articleBatchRun" class="com.cloudshield.hongce2.utils.quartzUtils.SpringQuartzJob" /> <!-- ============= 调度业务============= --> <bean id="articleBatchRunService" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- 要调用的对象 --> <property name="targetObject" ref="articleBatchRun" /> <!-- 要执行的方法名称 --> <!-- <property name="targetMethod" value="monitor" /> --> <property name="targetMethod" value="job" /> <!-- 如果前一个任务还没有结束第二个任务不会启动 false --> <property name="concurrent" value="false" /> </bean> <!-- ============= 调度触发器 ============= --> <bean id="articleBatchRunTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail" ref="articleBatchRunService" /> <!-- 每隔1分钟审批一次 --> <property name="cronExpression" value="0 0/30 * * * ?" /> </bean> <!-- quartz实例化5秒后执行一次job --> <bean id="taskJobTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"> <property name="jobDetail" ref="articleBatchRunService" /> <property name="startDelay" value="5000" /> <!-- 启动延迟 单位/毫秒--> <property name="repeatInterval" value="1000" /> <!-- 多久执行一次 单位/毫秒--> <property name="repeatCount" value="0" /> <!-- 重复次数 --> </bean> <!-- ============= 调度工厂 ============= 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 --> <bean id="schedulerBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"> <property name="triggers"> <list> <ref bean="articleBatchRunTrigger"/> <ref bean="taskJobTrigger"/> </list> </property> </bean>