How to get the id of a bean from inside the bean in Spring? How to get the id of a bean from inside the bean in Spring? spring spring

How to get the id of a bean from inside the bean in Spring?


Just implement the org.springframework.beans.factory.BeanNameAware interface and you will get it automatically. It has one method:

void setBeanName(String name)