I have a configuration file beans.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
">
<bean id="myBeanFactoryPostProcessor" class="com.ssll.MyBeanFactoryPostProcessor" />
<bean id="myobj" class="com.ssll.MyFoo">
<property name="realname" value="${dummy}" />
</bean>
</beans>
Here, com.ssll.MyBeanFactoryPostProcessor
is a class:
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
System.out.println("This is expected to called when the BeanFactory is created");
Properties p = Config.getZooProperties();
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setProperties(p);
cfg.postProcessBeanFactory(beanFactory);
}
}
But the postProcessBeanFactory
is never called, where I am wrong, please
help.
I made a small test project here https://github.com/yujiaao/spring4test