enhancement
A case:
@Bean
public SomeOne aBean() {
return new SomeOne();
}
@Bean
public AnotherOne aBean() {
return new AnotherOne();
}
In this case, I'll get NoSuchBeanDefinitionException
on autowiring AnotherOne
It is confusing because of the root of exception in bean names duplication on anotherOne overrides previous bean definition
I think It will be convenient to get a specific exception or warning. If there is already some mechanism please let me know and I'll request close the issue
Of course, it is about naming, and it should not be named as in the example above. But my point in case of carelessness and framework feedback
Comment From: abhishek-abhi
I want to contribute to resolve the issue. Can you assign this to me ?
Comment From: artemptushkin
@abhishek-abhi no, have no permissions. TY! Open a PR, I'll review
Comment From: snicoll
@abhishek-abhi thank you for offering to help. There is no need to ask for assignment, a note that states you'll provide a PR short term is more than enough. This issue hasn't been triaged by the team yet: to avoid you spending time for something that would'd be declined, please wait for an issue to be triaged and assigned to a milestone.
Comment From: snicoll
In this case, I'll get NoSuchBeanDefinitionException on autowiring AnotherOne
That's because you've overwritten one bean with another since they have the same ID (collected from the method name). This is indeed a surprising behavior and we've decided to deprecate it (it is already disabled by default in Spring Boot for quite a while).
See #31288