Charly :
I have the List of the requested user and I want to upload the list of the user every day at 7 pm on each day. how can i do that using Spring Boot.And yes, it should also check whether the list is available or not.
Pijotrek :
You can achieve this with @Scheduled
annotation in one of your methods of the bean. In order to enable scheduling you need to put @EnableScheduling
annotation in one of your config classes, can be the main class:
@SpringBootApplication
@EnableScheduling
public class TestingApplication {
public static void main(String[] args) {
SpringApplication.run(TestingApplication.class, args);
}
}
Then you create a class, annotate it with @Component
and create a method with @Scheduled
annotation with a cron statement inside:
@Component
public class MyWorkerComponent {
@Autowired
private MyListChecker myListChecker;
@Scheduled(cron = "0 0 19 * * ?")
public void doTheListThingy() {
if (myListChecker.isTheListAvailable()) {
// your task logic
}
}
}