1,自定義類spring
package com.jd.service.meeting.worker;
public class MyWorker {
public void running(){
System.out.println("hello, world!");
}
}spa
二 ,配置使用xml
<?xml version="1.0" encoding="GBK"?> get
<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.xsd"
default-autowire="byName">
<bean id="helloWorker" class="com.jd.service.meeting.worker.MyWorker"></bean>
<bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<bean class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="concurrent">
<value>false</value>
</property>
<property name="targetObject">
<ref bean="helloWorker" />
</property>
<property name="targetMethod">
<value>running</value>
</property>
</bean>
</property>
<property name="cronExpression">
<value>0/10 * * * * ?</value>
</property>
</bean>
</list>
</property>
</bean>
</beans> it