Quartz作业调度(2)
来源:互联网 发布:淘宝卖家在哪里看等级 编辑:程序博客网 时间:2024/05/22 12:52
在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" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd"><!-- 定时任务 --><bean id="quartzJob" class="com.test.quartz.ScheduleJob" scope="prototype" /><!-- 绑定任务bean 和目标方法 --><bean id="jobOne"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><property name="targetObject"><ref bean="quartzJob" /></property><property name="targetMethod"><value>JobOne</value></property><property name="concurrent" value="false" /></bean><!-- 设置执行时间 --><bean id="jobOneTrigger"class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"><property name="jobDetail" ref="jobOne"></property><!-- 系统会在每分钟的0秒执行调度任务。 --><property name="cronExpression"><!-- 每秒执行 --><value>0/30 * * * * ?</value></property></bean><!-- 定时任务2--><bean id="jobTwo"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><property name="targetObject"><ref bean="quartzJob" /></property><property name="targetMethod"><value>JobTwo</value></property><property name="concurrent" value="false" /></bean><!-- 设置执行时间 --><bean id="jobTwoTrigger"class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"><property name="jobDetail" ref="jobTwo"></property><!-- 系统会在每分钟的0秒执行调度任务。 --><property name="cronExpression"><!-- 每秒执行 --><value>0/1 * * * * ?</value><!-- 每分钟执行1次 --><!-- <value>0 0/01 * * * ?</value> --></property></bean><!-- 调度器执行 --><bean id="startQuertz" lazy-init="false"class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers" ><list><ref bean="jobOneTrigger" /><ref bean="jobTwoTrigger" /></list></property></bean></beans>
package com.test.quartz;import java.util.Date;public class ScheduleJob {public void JobOne(){System.out.println("Job 1 "+ new Date());}public void JobTwo(){System.out.println("Job 2 "+ new Date());}}
0 0
- Quartz作业调度(2)
- Quartz进行作业调度
- Quartz作业调度
- 作业调度之quartz
- Quartz 作业调度
- Quartz作业调度
- Quartz 作业调度
- 作业调度框架--Quartz
- quartz的作业调度
- quartz作业调度
- Quartz作业调度框架
- Quartz 作业调度框架
- Quartz作业调度框架
- 作业调度框架Quartz
- Quartz作业调度框架
- Quartz作业调度框架
- Quartz作业调度框架
- Quartz作业调度框架
- java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
- Multiple operations with path 'api/Plan/AllocateTransport' and method 'GET'
- 文章标题
- 随处可见的用户体验
- 【数据结构 队列 + 二叉树】
- Quartz作业调度(2)
- Android activity 概要
- Shell脚本接收有空格参数问题
- c# 线程中如何控制控件焦点
- Google glog
- Javascript操作DOM常用API总结
- svn
- 用MqttAndroidClient实现IM
- mysql5.7配置文件优化