日期:2014-05-18  浏览次数:20753 次

spring定时器不起作用
web.xml 配置
context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
            classpath:/applicationContext-resources.xml
            classpath:/applicationContext-dao.xml
            classpath:/applicationContext-service.xml
            classpath*:/applicationContext.xml
            /WEB-INF/applicationContext*.xml
                  </param-value>
</context-param>
applicationContext.xml  配置

<bean id="testtask" class="cn.com.base.webapp.Test"></bean>
    <bean id="dayClock" class="org.springframework.scheduling.timer.ScheduledTimerTask">
        <property name="timerTask"><ref bean="testtask"></ref></property>
        <property name="period"><value>10</value></property>
        <property name="delay"><value>10</value></property>
    </bean>
    
    <bean class="org.springframework.scheduling.timer.TimerFactoryBean">
        <property name="scheduledTimerTasks">
            <list>
                <ref bean="dayClock"></ref>
            </list>
        </property>
    </bean>
java 类
public class Test extends TimerTask {
    
    
    public void run() {
        System.out.println("定时任务 : " + new Date());
       
    }
}
没有起到效果,是什么原因啊

------解决方案--------------------
http://www.blogjava.net/Steven-bot/articles/363924.html
------解决方案--------------------
spring定时任务的几种实现http://gong1208.iteye.com/blog/1773177
------解决方案--------------------
你搜索下,最好用注解的方式, xml 定义的我感觉没有注解的方便。