SpringBoot_Topic6_DI_BeanManagement
SpringBoot_Topic6_DI_BeanManagement
Dependency Injection is a design pattern where the dependencies (objects a class needs) are provided by an
Types of DI in Spring:
Example: Constructor-Based DI
@Service
@RestController
@Autowired
this.myService = myService;
@GetMapping("/data")
Spring Beans:
Declaring a Bean:
- @Component
- @Service
- @Repository
- @Controller
@Configuration
@Bean
Interview Questions:
A: DI is a design pattern in which a class receives its dependencies from an external source.
A: