This can be done by specifying the cron expression
in your property place holder
as mentioned below. Add below code in @configuration
class.
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
properties.setLocation(new ClassPathResource("test.properties"));
return properties;
}
Now test.properties will be available in your placeholder. Test.properties shown below
variable.name.inside.properties= 00 39 05 * * *
Then inside your scheduler class add
@Scheduled(cron = "${variable.name.inside.properties}")
public void testMethod(){
doSomething();
}