Problem

ConfigurableListableBeanFactory getDependenciesForBean() & getDependentBeans() return empty array in BeanFactoryPostProcessor

Example

@Controller
class MyController(
    val myService: MyService
) {}

@Service
class MyService {}

@Component
class MyPostProcessor : BeanFactoryPostProcessor {

    override fun postProcessBeanFactory(beanFactory: ConfigurableListableBeanFactory) {
        val dependencies = beanFactory.getDependenciesForBean("myController") // Expecting ["myService"], but is empty []
        val dependents = beanFactory.getDependentBeans("myService") // Expecting ["myController"], but is empty []
    }

}

Comment From: snicoll

This is the expected behavior. Relationships between beans are set during bean post processing phase. This one in particular happens when AutowiredAnnotationBeanPostProcessor runs.

Your example is trivial as you have one type depending on another but the injection point may be much more complex than that, which needs to resolve the actual value to inject to do the right thing.