Spring Containers: BeanFactory and ApplicationContext Difference


the BeanFactory Container is the the lightweight Spring Container that Supports IOC ( Invertion of Control ).

Here are the required files to use the BeanFactory container.

1.) A POJO class – with a field, setter and getter
2.) A Main class – In this case, the main class will create the XMLBeanFactory. Upon creating the XMLBeanFactory, set the resource to the Spring Container xml configuration. which in this case would be Beans.xml
3.) Beans.xml – This is where we can set the fields of the POJO class. We even can set / create another class inside this class.

How does it work?

Once the main class creates the XMLBeanFactory, we can now use the Spring initializes POJO class.

See more details here:


BeanFactory is a lightweight version, so it comes in handy when resources are limited. But to get the full functionality of IOC in Spring, we have to Use ApplicationContext. ApplicationContext can do what a BeanFactory can do, but with more added features. It is described here below, as taken from Spring Official documentation on 3.8.1

Bean Factory

– Bean instantiation/wiring

Application Context

– Bean instantiation/wiring
– Automatic BeanPostProcessor registration
– Automatic BeanFactoryPostProcessor registration
– Convenient MessageSource access (for i18n)
– ApplicationEvent publication


To sum up the differences, Application Context has more functions for DI ( Dependency Injection ) initialization, and can modify the IOC Beans after initialization and some Event triggers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s