The BeanFactoryPostProcessor is useful for custom config files targeted at system administrators that override bean properties configured in the application context.

Use this to execute code once the BeanFactory itself has been initialised.



  • Create the class MyBeanFactoryPostProcessor that implements BeanFactoryPostProcessor
  • override the method postProcessBeanFactory
  • print a message in the method

Configure the PostProcessor Bean

Declare the MyBeanFactoryPostProcessor in the spring.xml

<bean class="com.skills421.examples.spring. MyBeanFactoryPostProcessor" />

Now Spring will call this method as soon as the BeanFactory is created (ApplicationContext)

Then, all the beans will be instantiated.

We can use this to plug in additional functionality to change the behaviour of the Spring Framework – for example, to read a property file of values for the beans in the spring.xml


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s