Difference between BeanFactory and ApplicationContext in Spring?

 BeanFactory-Does not support the Annotation based dependency Injection.
 ApplicationContext--Support Annotation based dependency Injection.-@Autowired, @PreDestroy
 BeanFactory-Does not Support
ApplicationContext- Application contexts can publish events to beans that are registered as listeners
BeanFactory-Does not support way to access Message Bundle(internationalization (I18N) 
ApplicationContext-Support internationalization (I18N) messages.
BeanFactory-Doesn’t support.
ApplicationContext-Support  many enterprise services such JNDI access, EJB integration, remoting.
BeanFactory-By default its support Lazy loading
ApplicationContext-- its By default support Aggresive loading.

16 comments :

  1. As per my experience, always prefer ApplicationContext over BeanFactory, there is absolutely no reason to use later.

    ReplyDelete
  2. Thanks for feedback but here we are only showing difference between BeanFactory and ApplicationContext..

    ReplyDelete
  3. As I know

    BeanFactory: Use Only when Resources are Crucial
    The root interface for accessing a Spring bean container

    ApplicationContext : we should generally use it.
    Subinterface of BeanFactory

    ReplyDelete
  4. 1) BeanFactory container is defined by the BeanFactory interface.
    Whereas ApplicationContext container is defined by the ApplicationContext interface.
    2) BeanFactory container is used for light weight applications.
    Whereas ApplicationContext container is used for heavy weight applications.

    Let me know if I am wrong. Thank you :)

    ReplyDelete
  5. The main difference between these two containers is how singleton beans are loaded. A bean factory lazily loads all beans, deferring bean creation until the getBean() method is called. An application context preloads all singleton beans upon context startup. By preloading singleton beans, you ensure that they will be ready to use when needed—your application won’t have to wait for them to be created.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  7. Thanks Remesh ��

    ReplyDelete
  8. Bean factory supports annotations by using manual registering bean post processor

    ReplyDelete
  9. Nice Info Regarding Bean Factory and application context in spring my sincere thanks for sharing this post Please Continue to share this post
    Java Training in Chennai

    ReplyDelete
  10. nice blog has been shared by you. before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
    Aws Training in Bangalore

    ReplyDelete
  11. Nice Info Regarding Bean Factory and application context in spring my sincere thanks for sharing this post Please Continue to share this post
    devops training in chennai

    ReplyDelete