Câu hỏi phỏng vấn Spring
Câu hỏi

What is Spring IoC Container?

Câu trả lời

The Spring IoC (Inversion of Control) Container is a core component of the Spring Framework, responsible for managing the lifecycle of Spring beans. It creates, configures, assembles, and manages the beans throughout their lifecycle. The IoC container uses Dependency Injection (DI) to provide the required dependencies to the beans it manages.

Key Functions of the Spring IoC Container:

  1. Bean Instantiation: The container is responsible for creating instances of beans. This can be done through constructors, factory methods, or other means defined in the Spring configuration[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].

  2. Dependency Injection: The IoC container injects dependencies into beans. Dependencies can be injected via constructor arguments or setter methods. This process is controlled by the configuration metadata provided by the developer, which can be in the form of XML, annotations, or Java-based configuration[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].

  3. Bean Configuration: The container manages various aspects of beans, such as setting properties and calling initialization and destruction methods. This configuration is also specified in the metadata[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].

  4. Lifecycle Management: The IoC container manages the complete lifecycle of the beans from instantiation to destruction. It ensures that beans are ready to use when needed and are disposed of properly when the application stops[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].

  5. Bean Scoping: Beans managed by the IoC container can be configured with different scopes, such as singleton (one instance per container) or prototype (new instance each time requested). The container is responsible for enforcing these scopes[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17].

Types of IoC Containers in Spring:

  • BeanFactory: The simplest containe...
middle

middle

Gợi ý câu hỏi phỏng vấn

junior

What are Spring beans?

middle

What is bean auto wiring?

senior

What are the disadvantages of using Reactive Streams?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào