user219882 user219882 - 1 year ago 130
Java Question

Spring Scheduler does not work

I have a problem with Spring's annotation based task scheduler - I can't get it working, I don't see any problem here...


<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="1" />
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler" />


public final class SchedulingTest {

private static final Logger logger = Logger.getLogger(SchedulingTest.class);

@Scheduled(fixedRate = 1000)
public void test() {
logger.debug(">>> Scheduled test service <<<");


Answer Source

If you want to use task:annotation-driven approach and your @Scheduled annotation is not working, then you most probably missed context:component-scan in your context xml. Without this line, spring cannot guess where to search for your annotations.

<context:component-scan base-package="..." />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download