You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 a component-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.
The text was updated successfully, but these errors were encountered:
SpringJavaConfigTest should never have worked. That base class who shadows the bean in the concrete class should not be created in the first place. Actually, we think that there's a case for throwing an exception for such an unusual use case.
From that perspective, the XML based test failing is the expected behavior. We'll tidy things up in 6.2.x to make things consistent.
snicoll
changed the title
Difference in context initialization between 5.2.8 and 5.2.9
Configuration class parsing registers bean in parent class if its @Bean declaration defines an alernative name
Nov 24, 2023
jhoeller
changed the title
Configuration class parsing registers bean in parent class if its @Bean declaration defines an alernative name
Configuration class parsing registers bean in parent class if overridden @Bean method defines an alternative name
Nov 24, 2023
bclozel
changed the title
Configuration class parsing registers bean in parent class if overridden @Bean method defines an alternative name
Configuration class parsing registers bean in parent class if overridden @Bean method defines an alternative name
Feb 14, 2024
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:
There are two tests in there:
@ContextConfiguration
annotation and gives it a java@Configuration
class@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.
The text was updated successfully, but these errors were encountered: