Bean is an important component in spring framework.
Bean is an object in spring. A bean is an object which is instantiated, configured, wired and managed by spring IOC container.
One can create as many beans in the spring as required.
These beans are created after the container reads the configuration metadata provided either:
through xml file or
java based or
In XML, bean can be created as shown below:
<bean class="com.javaradar.Employee. " id="emp"></bean>
This is the simplest way to create bean.
Here "class" refers to POJO java class for which you want spring container to create bean. And "id" is the identifier to recognize the bean and use it anywhere in the application.
One of the common place where you will always use the id is while calling this bean.
Further you can also provide other properties to the bean as shown below:
We will learn in depth about each of the properties in detail as we proceed further with this spring tutorial.
Moreover we will learn about other ways of creating bean like java based and autowired in respective sections.