How to parameterize @Scheduled Annotation in Spring 3.0 ?

Use the following code to parameterize @Scheduled annotation in Spring 3.0

public class SpringScheduler {

       
        @Scheduled(cron="${scheduler.cron}")
        public void run()
        {
                // code for the Scheduled task
        }
}

When the Spring container starts, the run() method will be executed as per the cron expression.
The "scheduler.cron" property should be provided in the properties file.

Search