- <?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">
- <!-- ArticlePushServiceImpl这个是我的实现类-->
- <bean id="pushService" class="com.funo.cms.service.impl.ArticlePushServiceImpl"></bean>
- <!-- 定时任务 -->
- <!-- 定义调用对象和调用对象的方法 -->
- <bean id="jobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <!-- 调用的类 -->
- <property name="targetObject">
- <ref bean="pushService" />
- </property>
- <!-- 调用类中的方法 -->
- <property name="targetMethod">
- <value>autoDatePush</value>
- </property>
- </bean>
- <!-- 定义触发时间 -->
- <bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
- <property name="jobDetail">
- <ref bean="jobtask" />
- </property>
- <!-- cron表达式 -->
- <property name="cronExpression">
- <!-- 每10秒执行一次 -->
- <value>0/10 * * * * ?</value>
- </property>
- </bean>
- <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
- <bean id="startQuertz" lazy-init="true" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <ref bean="doTime" />
- </list>
- </property>
- </bean>
- </beans>
spring定时器
最新推荐文章于 2021-02-16 08:58:23 发布