1

In my class I have an @Autowired bean which holds a cron expression in one of it's attributes.

In the same class I have a @Scheduled method, and I wish to set the cron expression to the bean's property.

I tried this already and it doesn't work

@Scheduled(cron = "#{propertyBean.cronExpression}")

Any ideas?

Thank you.

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
TheRock3t
  • 628
  • 9
  • 22
  • here maybe : http://stackoverflow.com/questions/15250928/how-to-change-springs-scheduled-fixeddelay-at-runtime seems possible with spring boot – lepak Aug 19 '16 at 09:31

1 Answers1

1

This annotation worked for me:

@Scheduled(cron = "${property.with.cron}")

With this in our spring profile/application.properties:

property.with.cron=*/10 * * * * *

We're using spring boot just fyi

Avery Sturzl
  • 82
  • 1
  • 13