user219882 user219882 - 8 months ago 63
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 <<<");



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="..." />