The short answer is impossible out of the box.
The value passed as the cron expression in the @Scheduled annotation is processed in the ScheduledAnnotationBeanPostProcessor class using an instance of the StringValueResolver interface.
StringValueResolver has 3 implementations out of the box - for Placeholder (for example, $ {}), for Embedded values ββand for Static Strings - none of which can achieve what you are looking for.
If you need to avoid using the property attribute in the annotation at all costs, get rid of the annotation and build everything programmatically. You can register tasks using ScheduledTaskRegistrar , which is what the @Scheduled annotation @Scheduled .
I suggest using everything that is the simplest solution that works and passes the tests.
hovanessyan
source share