<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<!--定义这个工作的任务-->
<bean id="jobDetailFactoryBean" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<!--这个叫做给任务取名字-->
<property name="name" value="myTask1"></property>
<!--这个叫做给任务分组-->
<property name="group" value="myTaskGroup1"></property>
<!--如果设置为false的话 没有活动的任务将会被删除-->
<property name="durability" value="true"></property>
<!--设置这个ob -->
<property name="jobClass" value="com.qf.shopping.task.MyTask"></property>
<!-- 指定spring容器的key,如果不设定在job中的jobmap中是获取不到spring容器的 -->
<property name="applicationContextJobDataKey" value="applicationContext"/>
</bean>
<!--定义的是定时任务的触发器-->
<bean id="cronTriggerFactoryBean" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<!--给这个触发器取名字-->
<property name="name" value="myTaskTrigger"></property>
<!--定义触发器的分组-->
<property name="group" value="myTaskTriggerGroup"></property>
<!--注入触发器的工作任务-->
<property name="jobDetail" ref="jobDetailFactoryBean"></property>
<!--定义的是触发器的事件格式的表达式-->
<property name="cronExpression" value="0/3 1 * * * ?"></property>
</bean>
<bean id="customJobFactory" class="com.qf.shopping.task.CustomJobFactory"></bean>
<!--定义的是调度器-->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTriggerFactoryBean"/>
</list>
</property>
<property name="jobFactory" ref="customJobFactory"></property>
</bean>
<!--配置的是Spring的扫描包-->
<context:component-scan base-package="com.qf.shopping.task" />
</beans>
Spring整合Quartz
猜你喜欢
转载自blog.csdn.net/LiDouDou1994/article/details/81502189
今日推荐
周排行