Tips and Tricks of Dependency Injection in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". In this post, we will discuss few more tips and tricks of dependency injection in Spring. There are different types of objects and primitive values which qualify to get injected into a bean. As a developer and architect, it is important for us to understand all these concepts. Here, in this post, we will try to discuss the ones which are frequently used. Injecting Primitives and Strings Beans can have properties which are ...
Read More

Setter Based Dependency Injection in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". As promised in the previous post, this post will help us understand the second form of dependency injections. Here I will introduce setter based dependency injection. Setter Based Dependency Injection There is another way of injecting dependencies into beans. After instantiating the bean, the container invokes the setter methods for the given property and sets the required property. Let us inject our DataStore bean into Or...
Read More

Constructor Argument Resolution – Constructor Based DI

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". As promised in the previous post, this post will help us resolve different ambiguities in constructor argument resolution. We will also talk about various possible ways of resolving constructor arguments. There are different variants of the problem with different types of configurations. For e.g. few problems/ambiguities which exists in XMLs might not be there in Annotation based configuration and so on. Hence, we will discu...
Read More

Constructor Based Dependency Injection in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". We now know a lot about Spring beans and in the last post we mentioned about the dependency injection. It precisely means, how to connect two beans when one bean is composed in another bean. So let us start with practical implementation of Constructor Based Dependency Injection in Spring. Constructor Based Dependency Injection Constructor Based Dependency Injection is the one in which the wiring between beans is achieved usin...
Read More

Bootstrap your Spring Application – Bean Collaboration

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". Now we know about the beans and the containers . We defined couple of beans as well. But what is an application good for if the beans do not interact? This post describes how to bootstrap your spring application. Almost all applications will need beans to collaborate with each other and deliver some results. And this is achieved using Dependency Injection. Recalling our discussion from the Inversion of Control post, if a con...
Read More