schedule task with spring mvc
Posted
by
user3586352
on Stack Overflow
See other posts from Stack Overflow
or by user3586352
Published on 2014-05-31T21:23:13Z
Indexed on
2014/05/31
21:24 UTC
Read the original article
Hit count: 189
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"/>
© Stack Overflow or respective owner