What's the difference between ApplicationContextInitializer and BeanFactoryPostProcessor? When to implement what interface?
Asked
Active
Viewed 1,021 times
1
-
1you can follow this bellow url: - http://stackoverflow.com/questions/30455536/beanfactorypostprocessor-and-beanpostprocessor-in-lifecycle-events – Anshul Sharma May 04 '17 at 18:40
1 Answers
5
My understanding of their difference is mainly in the time when their callback method is called.
ApplicationContextInitializer
allows you to do additional initialization before persistent bean definition is loaded (e.g. your application-context.xml
). Useful when you want to select profiles before you will load definitions.
BeanFactoryPostProcessor
is called when bean definitions are loaded but beans itself are not created. Great example is PropertyPlaceholderConfigurer
which replaces placeholders with concrete values.
You can dive deeper in relevant documentations.
ApplicationContextInitializer
and BeanFactoryPostProcessor

M. Deinum
- 115,695
- 22
- 220
- 224

chalimartines
- 5,603
- 2
- 23
- 33