spring 监听bean 加载

package com.until;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * 测试类   打印出加载的bean
 * @author Administrator
 *
 */
public class SpringBeanInitProcesser implements BeanPostProcessor {

 public Object postProcessAfterInitialization(Object bean, String beanName)
   throws BeansException {
  // TODO Auto-generated method stub
  //System.out.println("Bean '" + beanName + "' created : " + bean.toString());
  return bean;
 }

 public Object postProcessBeforeInitialization(Object bean, String beanName)
   throws BeansException {
  // TODO Auto-generated method stub
  System.out.println("Bean '" + beanName + "' created : " + bean.toString());
  return bean;
 }


}

你可能感兴趣的:(spring)