Sunday, June 20, 2021

What is dependency injection?

Ans: Dependency means something that is dependent on something .When an object dependent on another object then that object is the dependent object. Ex: if we assume car is an object then tire ,door, machine is the dependent object of car. So, dependency injection means of injecting dependent object from object factory(Spring container) throw constructor/setter/autowiring .

Dependency can be injected throw -

1.Constructor injection

2.Setter injection

3.Autowiring.

No comments:

Post a Comment

Testing controller

------Controller------------- @RestController @RequestMapping("/items") public class ItemController {     private final ItemServic...