spring 打印所有创建的beans
2021-06-28 14:06
标签:ica 就会 ring create public pos string ESS could 1,创建一个类,实现接口 BeanPostProcessor import org.springframework.beans.BeansException; public class GetBeansNames implements BeanPostProcessor { 2,在application.xml 中加入刚才创建的类名的bean 3,在启动tomcat的时候就会打印创建beans的名称 spring 打印所有创建的beans 标签:ica 就会 ring create public pos string ESS could 原文地址:https://www.cnblogs.com/albertzhangyu/p/9649080.htmlpackage com.zuikc.web.controller;
import org.springframework.beans.factory.config.BeanPostProcessor;
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean; // we could potentially return any object reference here...
}
//在创建bean后输出bean的信息
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("Bean ‘" + beanName + "‘ created : " + bean.toString());
return bean;
}
}
上一篇:Python 输出百分比
文章标题:spring 打印所有创建的beans
文章链接:http://soscw.com/index.php/essay/98931.html