I'm trying to create a `BeanPostProcessor` for registering some values to a Map.
The `BeanPostProcessor` works file if I'm create the bean instance via xml definition, but I change the bean definition to `@Configuration` class it is not working.
PostProcessor
Bean ConfigurationCode:public class InstantiationTracingBeanPostProcessor implements BeanPostProcessor { public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { System.out.println("Bean '" + beanName ); return bean; } }
Component scan ConfigurationCode:import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; @org.springframework.context.annotation.Configuration public class Configuration { @Bean public @Qualifier("InstantiationTracingBeanPostProcessor") InstantiationTracingBeanPostProcessor activitiConfigurationBeanPostProcessor() { return new InstantiationTracingBeanPostProcessor(); } }
The application just hangs if I use the above configuration. But if I use xml based configuration as given below it works fine.Code:<context:component-scan base-package="xyz.config"/> <context:annotation-config/>
I'm using spring 3.1.0.Code:<bean class="xyz.bean.InstantiationTracingBeanPostProcessor"/>
What am I doing wrong here?


Reply With Quote
