In Spring, what is the difference between BeanFactory and ApplicationContext?

In Spring, what is the difference between BeanFactory and ApplicationContext?

Ninja Asked on 17th September 2018 in Spring.
Add Comment
1 Answer(s)
Best answer

A BeanFactory is a factory class that holds bean definitions and then instantiates the beans whenever asked for by clients. It also creates dependencies between collaborating objects as they are instantiated. BeanFactory also enforces the life cycle of a bean, making calls to various initialization and destruction methods.

ApplicationContext is a more advanced container for beans. It provides all the BeanFactory functions like loading bean definitions, wiring beans together, and providing beans upon request. It also provides the following additional functions:

• A means for resolving text messages, including support for internationalization.
• A generic way to load file resources.
• Events to beans that are registered as listeners.

ApplicationContext is the preferred way to access beans in Spring.

Ninja Answered on 17th September 2018.
Add Comment