首页 > 代码库 > Spring定时实际项目运用

Spring定时实际项目运用

applicationContext-timer.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
	
	<!-- 微博数据抓取 -->
	<bean id="weiboManager" class="com.wiseweb.pom.service.weibo.WeiboStatusManager"></bean>
	<bean id="usersManager" class="com.wiseweb.pom.service.weibo.WeiboUsersManager"></bean>
	<bean id="assignUsersManager" class="com.wiseweb.pom.service.weibo.WeiboAssignUsersManager"></bean>
	<bean id="ntManager" class="com.wiseweb.pom.service.tracking.NegativeTrackingManager"></bean>
	<bean id="classPersonalManager" class="com.wiseweb.pom.service.classify.ClassPersonalManager"></bean>
	<bean id="searchManager" class="com.wiseweb.pom.service.docInfo.SearchManager"></bean>
	<bean id="cacheCountManager" class="com.wiseweb.pom.service.cache.CacheCountManager"></bean>
	<bean id="docInfoManager" class="com.wiseweb.pom.service.docInfo.DocInfoManager"></bean>
	<!-- 微博数据抓取 -->
	<bean id="weiboCrawJob" class="org.springframework.scheduling.quartz.JobDetailBean">
		<property name="jobClass" value=http://www.mamicode.com/"com.wiseweb.util.timer.SinaWeiboCrawTimer">>
给出某一个定时类的写法

package com.wiseweb.util.timer;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.wiseweb.pom.entity.CacheCount;
import com.wiseweb.pom.entity.ClassConfigPersonal;
import com.wiseweb.pom.entity.ClassTreePersonal;
import com.wiseweb.pom.entity.ClassTreePersonalKeyword;
import com.wiseweb.pom.entity.ClassifyPersonalRole;
import com.wiseweb.pom.entity.SearchInfo;
import com.wiseweb.pom.service.cache.CacheCountManager;
import com.wiseweb.pom.service.classify.ClassPersonalManager;
import com.wiseweb.pom.service.docInfo.SearchManager;

public class PersonalCrawTimer extends QuartzJobBean{
	private SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd") ;
    private SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ;
    private ClassPersonalManager classPersonalManager ;
    private SearchManager searchManager ;
    private CacheCountManager cacheCountManager ;
    private Integer order = 1; // 按时间排序
	private String queryValue = http://www.mamicode.com/"";>

Spring定时实际项目运用