Spring BeanFactory Container Example

By | March 2, 2021

In this post, we will look into Spring BeanFactory Container with an Example

The Spring IOC container

Spring IOC container is mainly responsible for instantiating, configuring, and assembling the Spring beans. The Spring container gets instructions on what are objects to instantiate, configure, and assemble by reading configurational metadata. The configurational metadata is represented in XML config file or Java annotations

Spring framework provides the following two types of containers.

  1. BeanFactory container
  2. ApplicationContext container

In this post, we post let’s have a look into Spring BeanFactory container using a demo Project.

Spring BeanFactory Container

  • This is the simplest container that provides the basic support for DI and defined by the org.springframework.beans.factory.BeanFactory interface.
  • XmlBeanFactory is the implementation class of BeanFactory 

pom.xml

Message.java

ApplicationContext.xml

ClientTest.java

If you run  ClientTest.java as Java Application then it will give the below output:

101 Welcome to Spring Framework!!

That’s all about Spring BeanFactory Container Example

You May Also Like:

Spring ApplicationContext Container Example
Annotation-based Configuration in Spring Framework Example
Spring Java-based Configuration Example
Spring Setter Dependency Injection Example
Spring @Autowired Annotation With Setter Injection Example
Spring Constructor based Dependency Injection Example
Spring @Autowired Annotation With Constructor Injection Example
Spring Autowiring byName & byType Example
getBean() overloaded methods in Spring Framework
Spring Inner bean example
Spring Dependency Injection with Factory Method
Spring Framework @Qualifier example
Injecting Collections in Spring Framework Example
Spring Bean Definition Inheritance Example
Spring bean scopes with example
Spring JSR-250 Annotations with Example
Spring BeanPostProcessor Example
Spring JDBC Integration Example
Spring JDBC Annotation Example
Spring with Jdbc java based configuration example
Spring JDBC NamedParameterJdbcTemplate Example
How to call stored procedures in the Spring Framework?

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published.