BeanFactory is the top-level interface in the Spring container. ApplicationContext is its subinterface.

The difference between BeanFactory and ApplicationContext is that the object is created at different points in time.

The BeanFactory interface

  • Spring’s original interface, the implementation class for the original interface is relatively simple.
  • The BeanFactory interface implements a container of classes that create objects each time they are acquired.

ApplicationContext

  • Each time the container is started, all the objects in the configuration file are created and more is provided.
Implementation class:
  • From the classpath loading the configuration file: ClassPathXmlApplicationContext
  • From the absolute path to the hard disk under loading the configuration file: FileSystemXmlApplicationContext (” d: / XXXX “)

Conclusion: In Web development, the ApplicationContext is used, and the BeanFactory is used when resources are scarce.