How are Spring objects represented at runtime?

后端 未结 4 1053
无人及你
无人及你 2020-12-09 04:58

I have an app that uses the \"task:scheduler\" and \"task:scheduled-tasks\" elements (the latter containing \"task:scheduled\" elements). This is all working fine.

4条回答
  •  伪装坚强ぢ
    2020-12-09 05:42

    With @Scheduled based configuration the approach from Tobias M’s answer does not work out-of-the-box.

    Instead of autowiring a ScheduledTaskRegistrar instance (which is not available for annotation based configuration), you can instead autowire a ScheduledTaskHolder which only has a getScheduledTasks() method.

    Background:

    The ScheduledAnnotationBeanPostProcessor used to manage @Scheduled tasks has an internal ScheduledTaskRegistrar that’s not available as a bean. It does implement ScheduledTaskHolder, though.

提交回复
热议问题