Java – how to schedule a task every “n” seconds in the spring framework
How to connect to my web XML task occurs every N seconds In addition, I need to refresh the server method every 5 seconds through method calls
Thank you very much in advance
Solved:
http://javaprogrammingtips4u.blogspot.com/2010/05/how-to-implement-task-scheduler-job.html
Solution
You can use the routines required for annotation
public class Foo { @Scheduled(fixedDelay=5000) public void Bar() { // ... } }
However, in order for spring to find and recognize annotations, you must declare the basic package of class Foo and configure spring to find and schedule tasks Put the following in the spring XML configuration (and don't forget to import the XML namespace contextand task)
<context:component-scan base-package="com.company.scheduling"/> <task:annotation-driven />
Alternatively, you can place @ enableschedging before the class declaration, which will provide you with XML configuration out of the box
See also the context namespace and the task namespace