Two @Bean
methods with the same bean name should consistently throw an exception
#33330
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Affects: spring version: 6.1.11, spring-boot version: 3.3.2
It confuses me that when I use the
@Bean
method to register two beans with the same name into the container and start the Spring application context, it succeeds. However, if I use@Component
to register two beans with the same name into the container and start the context, it throws an exception. Why does this happen, and how should I understand it?example1: the method named beanA will execute and beanB will be ignored, start Spring application context will succeed. It seems always execute above method
example2 will throw an exception
The text was updated successfully, but these errors were encountered: