解决方案 »

  1.   

    看来CSDN已经不行了!发个帖几天都没人回.......连灌水的都没了.....
      

  2.   

    怎么可能~我刚刚弄完这个spring的定时器demo,完全可以的啊
      

  3.   

    代码:
    @Component
    public class Job {


    @Scheduled(cron="0 0/1 * * * ?")//一分钟更新一次
    public void test0(){
    System.out.println("test0->"+new Date());
    }

    @Scheduled(cron="0/30 * * * * ?")//30秒更新一次
    public void test1(){
    System.out.println("test1->"+new Date());
    }

    @Scheduled(fixedDelay=30000)
    public void test2(){
    System.out.println("test2->doing fixedDelay->"+new Date());
    }

    @Scheduled(fixedRate=5000)
    public void test3(){
    System.out.println("test3->doing fixedRate->"+new Date());
    }

    @Scheduled(cron="0/5 * * * * ?", initialDelay=1000)
    public void test4(){
    System.out.println("test4->doing initialDelay->"+new Date());
    }}spring-*.xml<task:scheduler id="scheduler" pool-size="10" />  
        <task:executor id="executor" keep-alive="3600" pool-size="100-200" 
        queue-capacity="500" rejection-policy="CALLER_RUNS" /> 
        <task:annotation-driven executor="executor" scheduler="scheduler" />
      

  4.   

    我直接导入的org.springframework.scheduling.annotation.Scheduled
    一会儿我试试你那个····
      

  5.   

    我直接导入的org.springframework.scheduling.annotation.Scheduled
    一会儿我试试你那个····
    这与你导入什么东西无关,只要你有类似于spring-context-3.2.0.M1.jar这样的包就行,当然,我这个是3.2,你的可能是其它版本也不一定。然后就打开定时任务的配置,大概如下:
    <task:scheduler id="scheduler" pool-size="10" />  
        <task:executor id="executor" keep-alive="3600" pool-size="100-200" 
        queue-capacity="500" rejection-policy="CALLER_RUNS" /> 
        <task:annotation-driven executor="executor" scheduler="scheduler" />
    然后,你就可以在你的类里用@Scheduled注解来做定时任务了
      

  6.   

    @Configuration
    @EnableScheduling
    public class Tasker {}
      

  7.   

    我直接导入的org.springframework.scheduling.annotation.Scheduled
    一会儿我试试你那个····
    这与你导入什么东西无关,只要你有类似于spring-context-3.2.0.M1.jar这样的包就行,当然,我这个是3.2,你的可能是其它版本也不一定。然后就打开定时任务的配置,大概如下:
    <task:scheduler id="scheduler" pool-size="10" />  
        <task:executor id="executor" keep-alive="3600" pool-size="100-200" 
        queue-capacity="500" rejection-policy="CALLER_RUNS" /> 
        <task:annotation-driven executor="executor" scheduler="scheduler" />
    然后,你就可以在你的类里用@Scheduled注解来做定时任务了
    我现在的情况属于偷了个懒  没有做任何配置,直接使用的@Scheduled
      

  8.   

    我直接导入的org.springframework.scheduling.annotation.Scheduled
    一会儿我试试你那个····
    这与你导入什么东西无关,只要你有类似于spring-context-3.2.0.M1.jar这样的包就行,当然,我这个是3.2,你的可能是其它版本也不一定。然后就打开定时任务的配置,大概如下:
    <task:scheduler id="scheduler" pool-size="10" />  
        <task:executor id="executor" keep-alive="3600" pool-size="100-200" 
        queue-capacity="500" rejection-policy="CALLER_RUNS" /> 
        <task:annotation-driven executor="executor" scheduler="scheduler" />
    然后,你就可以在你的类里用@Scheduled注解来做定时任务了
    我现在的情况属于偷了个懒  没有做任何配置,直接使用的@Scheduled能跑任务就OK了