Configuration class parsing registers bean in parent class if overridden @Bean method defines an alternative name #28286
Closed
Description
We are experiencing a difference in behaviour when setting up a spring context in junit tests.
Here is a simple project that shows the difference: https://github.com/mpiela/spring-ctx-bug.
Usage:
mvn test
There are two tests in there:
- SpringJavaConfigTest.java - uses
@ContextConfiguration
annotation and gives it a java@Configuration
class - SpringXmlComponentScanTest.java - also uses a
@ContextConfiguration
but gives it a xml configuration file which in turn just does acomponent-scan
.
The issue seems to be with an overriden @Bean
method in a @Configuration
class and omitting the bean name in the subclass.
Both of these tests pass on Spring 5.2.8. When we switched to Spring 5.2.9 the one with the xml configuration file starts failing.
I am not really sure if this is a bug that's been fixed in 5.2.8 and 5.2.9 is the expected behaviour or if it is the other way around.