Spring
June 6, 2020

M01 Q22 What is the default bean id if you only use @Bean? How can you override this?

When using @Bean without specifying name or alias, the default bean ID will be created based on the name of the method which was annotated with @Bean annotation.

You can override this behaviour by specifying name or aliases for the bean. Alias is always the second name of the bean. The first name will become the ID.