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

What is the difference between Bean Factory and ApplicationContext?

Câu trả lời

The difference between BeanFactory and ApplicationContext in the Spring Framework is a common interview question that touches on the core concepts of Spring's Inversion of Control (IoC) container.

BeanFactory

  • Basic IoC Container: BeanFactory is the fundamental Spring IoC container that provides basic features for managing beans, such as bean instantiation and dependency injection[1][2].
  • Lazy Loading: It instantiates beans on-demand, typically when you call the getBean() method. This approach is known as lazy loading[3][8].
  • Limited Features: BeanFactory offers a limited set of features and is suitable for lightweight applications or scenarios with strict memory constraints[2][4].
  • Manual Configuration: Some features like BeanPostProcessor and BeanFactoryPostProcessor require explicit manual registration when using BeanFactory[2][6].
  • Limited Scope: It supports only Singleton and Prototype bean scopes and does not inherently support annotations or advanced enterprise features[1][4].

ApplicationContext

  • Advanced IoC Container: ApplicationContext builds on top of the BeanFactory and provides additional features, making it a more advanced IoC container[1][2].
  • Eager Loading: Unlike BeanFactory, ApplicationContext eagerly instantiates singleton beans at the time of container startup, which can lead to faster response times post-startup because all beans are preloaded[3][8].
  • Additional Features: It offers advanced features such as internationalization, event propagation, application lifecycle events, and built-in support for AOP (Aspect-Oriented Programming)[1][2].
  • **Automa...
middle

middle

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

middle

How is the right View chosen when it comes to the rendering phase?

expert

Where does the @Transactional annotation belong?

junior

What is the DispatcherServlet and what is it used for?

Bình luận

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

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