I have a Spring Boot app where I want to have multiple methods to run at different times of the day. The first one runs, but no subsequent method runs. What do I need to do to fix this? Here is my code: @EnableScheduling @Configuration //@ConditionalOnProperty(name = "spring.enable.scheduling") @SpringBootApplication @PropertySources({ @PropertySource(value = "prop.properties", ignoreResourceNotFound = true) }) public class Application { private static final Logger LOGGER = LoggerFactory.getLogger(Application.class); public static MyClass class = new MyClass(); public static void main(String[] args) { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); InputStream resourceAsStream = classLoader.getResourceAsStream("log4j2.properties"); PropertyConfigurator.configure(resourceAsStream);
SpringApplication.run(Application.class, args);
}
@Scheduled(cron = "${4am.cron.expression}", zone = "America/New_York") //0 0 6 * * ?
public void method1() {
something;
}
@Scheduled(cron = "${10am.cron.expression}", zone = "America/New_York") //0 0 6 * * ?
public void method2() {
something;
}
@Scheduled(cron = "${10am.cron.expression}", zone = "America/New_York") //0 0 6 * * ?
public void method3() {
something;
}
@Scheduled(cron = "${330pm.cron.expression}", zone = "America/New_York") //0 0 6 * * ?
public void method4() {
something;
}
@Scheduled(cron = "${430pm.cron.expression}", zone = "America/New_York") //0 0 6 * * ?
public void stopExecutor() {
MyClass class = new MyClass();
Executor executor = new Executor(class);
executor.stop();
}
@Configuration
class. – Amit Phaltankar