Posted on 2016-02-01 12:39
魔のkyo 阅读(272)
评论(0) 编辑 收藏 引用 所属分类:
JAVA 、
JSP
applicationContext.xml
<!-- Job -->
<bean id="couponExpiringNoticeJob" class="com.ff.job.CouponExpiringNoticeJob" />
<!-- 定义目标bean和bean中的方法 -->
<bean id="springQtzJobMethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="couponExpiringNoticeJob"/>
</property>
<property name="targetMethod"> <!-- 要执行的方法名称 -->
<value>execute</value>
</property>
</bean>
<!-- 调度触发器 -->
<bean id="cronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="springQtzJobMethod"></property>
<property name="cronExpression" value="0 46 10 * * ?"></property>
</bean>
<!-- 调度工厂 -->
<bean id="springJobSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTriggerBean"/>
</list>
</property>
</bean>
java
package com.ff.job;
import java.util.Date;
public class CouponExpiringNoticeJob {
public void execute() {
long ms = System.currentTimeMillis();
System.out.println("\t\t" + new Date(ms));
}
}