Jyotirup
Jyotirup

Reputation: 2920

when to use BeanFactory in actual application in spring?

From what I have read we should use BeanFactory when we are only looking for a light weight IOC quoting from Pro Spring 2.5

Unless you are looking for a really lightweight IoC solution for your application, you should almost certainly use ApplicationContext.

Is there any other compelling reason to use BeanFactory over ApplicationContext?

Upvotes: 0

Views: 1355

Answers (1)

Michael W
Michael W

Reputation: 3555

BeanFactory will only carry out Bean instantiation and wiring. ApplicationContext extends the functionality of BeanFactory and includes support for BeanPostProcessor which is required for Transactions and AOP.

The only real advantage of using BeanFactory is memory consumption if your app is only using spring for IOC.

Please also read the spring docs for a more in depth answer:

3.8.1. BeanFactory or ApplicationContext?

Upvotes: 1

Related Questions