Spring – Dependency Injection
The Dependency Injection is a design pattern that removes the dependency of the programs. In such case we provide the information from the external source such as XML file. It makes our code loosely coupled and easier for testing.
In Spring framework, we can perform Dependency Injection in two ways
1.Setter Injection:
we can perform DI using setter methods with
following Datatypes
- Primitive Types
- Object Types
- Collection Types
2.Constructor Injection:
we can perform DI using Constructors with
following Datatypes
- Primitive Types
- Object Types
- Collection Types
PREVIOUSSpring Introduction
NEXTSetter Injection