Spring - Types of DI
Types of DI:
* Constructor Based
If you achieve the DI using Constructor then it is called Constructor based DI
Class Driver{
private Licence licence;
@Autowired
public Driver(Licence licence){
this.licence = licence;
}
}
* Setter Based
If you achieve the DI using Setter method then it is called Constructor based DI
Class Driver{
private Licence licence;
@Autowired
public void setLicence(Licence licence){
this.licence = licence;
}
}
* Constructor Based
If you achieve the DI using Constructor then it is called Constructor based DI
Class Driver{
private Licence licence;
@Autowired
public Driver(Licence licence){
this.licence = licence;
}
}
* Setter Based
If you achieve the DI using Setter method then it is called Constructor based DI
Class Driver{
private Licence licence;
@Autowired
public void setLicence(Licence licence){
this.licence = licence;
}
}
Comments
Post a Comment