Dependency Injection, Beans and Spring Boot
45 min · Advanced
Spring is a framework whose core is a container that creates your objects (beans) and connects them, so classes receive their dependencies instead of building them. Spring Boot adds auto-configuration and starters so an app runs with almost no setup. These are the most asked topics for Java backend roles; Section 15 (Spring Framework & Spring Boot) taught them, and this lesson is the revision.
Topics in this lesson
- IoC and DI; constructor vs field injection
- @Component, @Service, @Repository, @Controller and @Bean
- Bean scopes, lifecycle, and choosing between multiple beans
- How Spring Boot auto-configuration works
- @RestController vs @Controller; @ControllerAdvice; profiles
Interview questions this lesson answers
- What is the Spring Framework?
- What is Spring Boot, and how is it different from Spring?
- What is Inversion of Control?
- What is Dependency Injection?
- What are the types of dependency injection in Spring?
- Why is constructor injection preferred over field injection?
- Is @Autowired required on a constructor?
- What is a Spring bean?
- What is the difference between BeanFactory and ApplicationContext?
- What is the difference between @Component, @Service, @Repository and @Controller?
Sign in free to continue this lesson
Create a free account to read every lesson, practise with the exercises and keep track of your progress.