标签:
public class QuartzJob1 extends QuartzJobBean{ @Override protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException { SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss"); System.out.println("传统方法被调用"+sdf.format(new Date())); } }
<!-- 注入调度类对象 -->
<bean id="quartzJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>action.QuartzJob1</value>
</property>
<!-- <property name="jobDataAsMap">
<map>
<entry key="command">
<value>更新</value>
</entry>
</map>
</property> -->
</bean>
<!-- 定义触发器-简单触发器 -->
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="quartzJob1"/>
<property name="startDelay" value="1000"/>
<property name="repeatInterval" value="2000"/>
<property name="repeatCount" value="5"/>
</bean>
<!-- 启动任务 -->
<bean id="quartzFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="simpleTrigger"/>
</list>
</property>
</bean>
public class Test1 { public static void main(String[] args) { ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext1.xml"); } }
标签:
原文地址:http://www.cnblogs.com/6da6da/p/4693312.html