aware
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
AwareBeanNameAwarebeanNameAware可以获得容器中Bean的名称,作用于每一个Bean。当bean被创建的时候设置他的名字,在基本properties填充完成以后,init调用前执行
摘自: spring-beans:5.3.4 org.springframework.beans.factory.BeanNameAware
Set the name of the bean in the bean factory that created this bean. Invoked after population of normal bean properties but before an init callback such as {@link InitializingBean#afterPropertiesSet()} or a custom init-method.
123456789101112package com.example.demo;import org.springframework.beans.factory.BeanNameAware;import org.springframework.stereotype.Component;@Componentpublic class BeanNameAwareDemo implements BeanNameAware { @Override public void setBeanName(String name) { System.out.println(name); }}
阅读全文…