标签:
1、Spring新型方式无需继承哪个类
public class QuartzJob2{ public void test(){ SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss"); System.out.println("Spring新型方法-使用简单触发器-被调用"+sdf.format(new Date())); } }
<!-- 注入调度类对象 -->
<bean id="quartzJob2" class="action.QuartzJob2"/>
<!-- 注入任务调度管理类对象-->
<bean id="methodInvoking" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="quartzJob2"/>
<property name="targetMethod" value="test"/>
</bean>
<!-- 定义触发器-简单触发器 -->
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="methodInvoking"/>
<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 Test2 { public static void main(String[] args) { ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext2.xml"); } }
标签:
原文地址:http://www.cnblogs.com/6da6da/p/4693324.html