see doc
'This is done by accessing the ApplicationContext’s BeanFactory through the getBeanFactory() method, which returns the DefaultListableBeanFactory implementation.'
It seems there is not method getBeanFactory() presented in ApplicationContext, not only that even after considering all it's sub classes there is not such method. but there indeed is public method to obtain BeanFactory but through ConfigurableApplicationContext.