<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="scheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
lazy-init="false">
<!-- <property name="startupDelay" value="10" /> -->
<property name="triggers">
<list>
<!-- 定时问好 -->
<ref local="sayHelloTirgger" />
</list>
</property>
</bean>
<!-- 定时问好 begin -->
<bean name="sayHelloJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass"
value="com.main.scheduler.job.TimeSayHelloJob" />
<property name="applicationContextJobDataKey" value="applicationContext" />
</bean>
<bean id="sayHelloTirgger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="sayHelloJob" />
<property name="cronExpression">
<value>0/6 * * * * ?</value><!--每6秒 -->
</property>
</bean>
<!-- 定时问好 end -->
</beans>
spring4 quartz 实现定时器功能
最新推荐文章于 2021-02-23 22:44:43 发布