How to load a cron expression from db and reschedu

2019-02-16 14:33发布

问题:

I'm using Spring scheduling to have batches in my application.

@Scheduled(cron = "${batch.name|0 0 21 * * ?}")
public void restart() { }

Values are load from a properties file and default value from the @Scheduled annotation parameter.

Now, I would like to be able to load a cron value from database (so from an object) without using Quartz library, only with the default Spring scheduler.

Does someone know if and how it is possible?

Thank you in advance.

回答1:

I found a solution by following this : Spring @Scheduled annotation

and this : http://tutorials.jenkov.com/java-util-concurrent/scheduledexecutorservice.html