Spring Boot

Spring Core - IoC & DI

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

22 面接問題·
Junior
1

What is Inversion of Control (IoC) in Spring?

回答

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?

回答

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?

回答

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 面接問題

次の面接に向けてSpring Bootをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める