1.使用maven加载 quarts 的jar
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.0</version>
</dependency>
2.spring 中配置 bean
<!-- schedule all jobs for quartz-->
<bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="dataScanTrigger1" />
<ref local="dataScanTrigger2" />
</list>
</property>
</bean>
//定义触发器
<bean id="dataScanTrigger1" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="scanJobDetail1" />
</property>
<property name="cronExpression">
<value>0 */1 * * * ?</value>//触发器执行的时间
</property>
</bean>
//定义具体的实现类 实现方法
<bean id="scanJobDetail1" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="dataScan" />
</property>
<property name="targetMethod">
<value>scanShopsInfo</value>
</property>
<property name="concurrent">
<value>false</value>
</property>
</bean> <bean id="dataScanTrigger2" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="scanJobDetail2" />
</property>
<property name="cronExpression">
<value>0 50 23 * * ?</value>
</property>
</bean>
<bean id="scanJobDetail2" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="dataScan" />
</property>
<property name="targetMethod">
<value>scanOrder</value>
</property>
<property name="concurrent">
<value>false</value>
</property>
</bean>
DataScan.java
public class DataScan { /**
*
* @author:jason_zhangz@163.com
* @time:2016-8-26下午4:50:35
* @des:扫描
*/
public void scanOrder(){ //对beautyShop 进行空查询,获取所有的 shopId ,shopName
List<BeautyShop> shops = beautyShopOperator.getAllBeautyShopInaCity(null);
orderOperator.staGetStatisticOrders(shops); } ...... }