schedule task with spring mvc
- by user3586352
I want to run the following method every specific time in spring mvc project it works fine and print first output
but it doesn't access the database so it 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>
<!-- The bean that does the actual work -->
<bean id="ScheduleService" class="com.ctbllc.ctb.scheduling.ScheduleService" />
<!-- Defines a ThreadPoolTaskScheduler instance with configurable pool size. -->
<task:scheduler id="taskScheduler" pool-size="1"/>