Spring Boot

Spring Core - IoC & DI

Inversion of Control, Dependency Injection, annotations (@Component, @Autowired, @Bean), scopes, bean lifecycle

22 pytań z rozmów·
Junior
1

What is Inversion of Control (IoC) in Spring?

Odpowiedź

IoC is a principle where the Spring framework manages object creation and lifecycle, rather than the developer. This reverses the traditional control flow where application code directly instantiates its dependencies. Spring uses an IoC container to manage beans and their dependencies declaratively.

2

What is a bean in Spring?

Odpowiedź

A bean is an object managed by the Spring IoC container. It is instantiated, configured and assembled by Spring according to configuration metadata (annotations, XML or Java config). Beans are the core of a Spring application and benefit from dependency injection.

3

What is the purpose of the @Component annotation?

Odpowiedź

The @Component annotation marks a class as a Spring bean to be automatically detected during component scanning enabled by @ComponentScan. Spring creates an instance of this class and places it in the IoC container with a default name (class in camelCase). It's the generic stereotype annotation from which @Service, @Repository and @Controller derive to bring specific business semantics.

4

What are the three types of dependency injection in Spring?

5

How does the @Autowired annotation work?

+19 pytań z rozmów

Opanuj Spring Boot na następną rozmowę

Uzyskaj dostęp do wszystkich pytań, flashcards, testów technicznych, ćwiczeń code review i symulatorów rozmów.

Zacznij za darmo