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;
}

}

Comments

Popular posts from this blog

How to set Java Object into JaxBElement ?

GitLab