Back to course

Dependency Injection (DI) Concepts

Spring Boot 0 to Hero: The Complete Java Backend Masterclass

Dependency Injection (DI)

DI is a design pattern in which an object receives other objects that it depends on.

In Spring, you don't use new MyService(). Instead, Spring 'injects' the instance into your class. This makes your code modular, testable, and loosely coupled.