spring Bean Overriding 2.1.x in nested class @Configuration @Bean creation fails with 'A bean with that name has already been defined' [SPR-17365] #21898
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: waiting-for-triage
An issue we've not yet triaged or decided on
Dirk Hoffmann opened SPR-17365 and commented
upgrading to spring-boot 2.1.0.M4 Bean overriding has been disabled by default.
If you are relying on overriding, you will need to set spring.main.allow-bean-definition-overriding to true.
But why is a Bean defined in an inner class also treated like a duplicate bean definition. Is this a bug? or has this some explanation?
e.g.:
works fine up to spring-boot 2.0.x
but when using e.g. spring-boot 2.1.0.M4 it gives me an error on startup:
As I clearly only have a single definition of the bean (only defined in an inner
@Configuration
class) this seems like a bug to me.If you ask why I am using a nested inner
@Configuration
class:I often have demo code, demonstrating distributed system behavior in which I need more than one app to demonstrate things. As I don't want to have multiple App code, I just start the same App with different profiles and the profile is injecting "different business logic" which I want to "keep together" in one file, like:
source code at: git@gitlab.com:hoffi_scratch/di.git
Affects: 5.1 GA
Reference URL: https://gitlab.com/hoffi_scratch/di
The text was updated successfully, but these errors were encountered: