java - schedule task with spring mvc -


i want run following method every specific time in spring mvc project works fine , print first output doesn't access database doesn't display list

the method

 public class scheduleservice {  @autowired private userdetailservice userdetailservice;  public void performservice() throws ioexception {     system.out.println("first output");     list<userdetail> list=userdetailservice.getall();     system.out.println(list);  } 

config file

 <!-- spring's scheduling support --> <task:scheduled-tasks scheduler="taskscheduler">    <task:scheduled ref="scheduleservice" method="performservice" fixed-delay="2000"/> </task:scheduled-tasks>  <!-- bean actual work --> <bean id="scheduleservice" class="com.ctbllc.ctb.scheduling.scheduleservice" />  <!-- defines threadpooltaskscheduler instance configurable pool size. --> <task:scheduler id="taskscheduler" pool-size="1"/>       

try (and remove bean definition xml file):

@component public class scheduleservice {      @autowired     private userdetailservice userdetailservice;      @scheduled(fixeddelay = 2000l) // in msec     public void performservice() throws ioexception {         system.out.println("first output");         list<userdetail> list=userdetailservice.getall();         system.out.println(list);      }  } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -