Suzan Cioc
Suzan Cioc

Reputation: 30097

How to initialize bean's property to its name from Spring context?

Is it possible to know bean's name from @Bean-annotated method and put it into this same bean's property, so that bean knows its own name?

If this way is impossible, then if there another way exist?

Upvotes: 2

Views: 169

Answers (1)

Random42
Random42

Reputation: 9159

Yes, there is the interface BeanNameAware which should be implemented by your bean.

Upvotes: 3

Related Questions