Author: UshaK
Spring Bean Lifecycle Callback Methods

In Spring framework it is the Spring container that is responsible for instantiating beans, setting bean properties, wiring dependencies and managing the complete bean lifecycle from its instantiation to the time bean is destroyed. Table of contents Spring bean lifecycle callbacks Spring bean lifecycle callback methods Spring bean lifecycle callback…
Injecting List, Set or Map in Spring
When you inject dependencies in Spring using value or ref attribute you can set a single primitive value or a single referenced bean. What if you want to inject a collection of values as a bean dependency in Spring, for that Spring framework provides an option to inject collections like…
Injecting Null and Empty String Values in Spring
In this post we’ll see how to inject null and empty string values into constructor argument or property in Spring. Injecting empty string in Spring In Spring if you have to set any property to the empty String value then pass (“”) as a value for that property. For example…
Advantages and Disadvantages of Autowiring in Spring
Autowiring in Spring makes life easy for the developer as the Spring container takes up the responsibility of autowiring relationships between collaborating beans by referring the contents of the ApplicationContext. Spring autowiring brings certain advantages at the same time autowiring has certain limitations and disadvantages. In this post we’ll have…
Exclude Bean From Autowiring in Spring
If you want to exclude bean from autowiring in Spring on a per-bean basis then in Spring’s XML format it can be done by setting autowire-candidate attribute of the <bean/> element to false. The Spring container makes that specific bean definition unavailable for autowiring (that is applicable to annotation style…
Spring Autowiring Using @Autowired Annotation
In Spring framework we provide configuration data using which Spring container can instantiate beans and inject dependencies. Autowiring in Spring means Spring container can automatically resolve collaboration among beans (bean dependencies) by inspecting the contents of the ApplicationContext. Table of contents Spring Autowiring Modes Autowiring in Spring Enabling @Autowired annotation…
Spring Autowiring Example Using XML Configuration
Autowiring in Spring means Spring container can automatically resolve collaboration among beans (bean dependencies) by inspecting the contents of the ApplicationContext. Ways to Autowire in Spring For autowiring in Spring there are three options. You can choose to autowire using the traditional XML based configuration. Autowiring using @Autowired annotation. Refer…
Circular Dependency in Spring

In this post we’ll see what is circular dependency in Spring and how to resolve circular dependencies. Circular dependency in Spring If you mostly use constructor dependency injection, it is possible to create an unresolvable circular dependency scenario. For example; Class A requires an instance of class B through constructor…
Spring IoC Container Types – ApplicationContext and BeanFactory

One of the main component of the Spring framework is the Spring IOC container which is responsible for instantiating beans, wiring dependencies and managing the bean lifecycle from its instantiation till destruction. The org.springframework.beans and org.springframework.context packages are the basis for SpringFramework’s IoC container. Based on these two packages Spring…