tl;dr: Can you think of any case I could look for where @Scheduled tasks are not executed in a Spring Boot app?
I implemented the example and it worked just fine, however, in a more complex Spring Boot app I am working on I can't get the @Scheduled methods to run.
My main class looks like this:
package com.mypackage.myapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@SpringBootApplication
@EnableWebSecurity
@EnableScheduling
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class);
}
}
and the component in which the scheduled app lives looks like this:
(...)
@Component
public class MyComponent {
private static final Logger logger = LoggerFactory.getLogger(MyComponent.class);
(...)
@Scheduled(fixedRate = 5000)
public void myScheduledTask() {
logger.info("Executing scheduled task");
(...)
}
}
The whole application is obviously more complex, but this is essentially it. Unfortunately, "Executing scheduled task" appears no where in the logs, also if I debug the breakpoint is never reached.
As I said, the minimal example works for me, however in my app it isn't. Can you think of any case I could check for where @Scheduled tasks are not executed? For example, can the configuration be overruled by anything? Can anything interfere?
I am using version 1.5.1.RELEASE.