@Bean fun beanADependsOnBeanB(): BeanFactoryPostProcessor { return BeanFactoryPostProcessor { beanFactory -> val taskQueueStarterBean = beanFactory.getBeanDefinition("beanA") taskQueueStarterBean.setDependsOn("beanB") } } spring