-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Regression in 4.1.5: Alternative @Bean declarations with same primary bean name do not work anymore [SPR-12744] #17341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented I'm pretty sure this is caused by #17292, where the revised algorithm apparently considers your same-named definitions as an override, only evaluating one of them and considering the definition as skipped. My apologies, that's of course an unintended side effect... The problem originates in the I suppose the reason for that explicit name is the That said, we'll fix this for 4.1.6 in any case. Juergen |
Juergen Hoeller commented One more note: You could also declare the bean names using aliases, a la
using a unique primary bean name and an alias to refer to for depends-on declarations. This is probably the most straightforward workaround and hopefully lowers the impact of this issue for the time being. Juergen |
Martin Wegner commented Thank you and until 4.1.6 I will use 4.1.4 :) All my beans have names :) Hm OK, it seems to be a good idea to use an argument instead of a
What is the advantage of this notation? |
Juergen Hoeller commented The advantage of this notation is simply that there are unique bean names to refer to - so at runtime (both within the framework and for live-beans monitoring etc), it's immediately clear which one of the beans has been selected for registration. The fact that you need to talk to them as one 'common' bean is then expressed through the shared alias. Juergen |
Juergen Hoeller commented Fixed through just checking for equivalent method names, not bean names, as it should arguably have been right from the start. Condition overriding with a same-named but overloaded method declaration still works but just specifying the same bean name is not sufficient for a condition override anymore. Juergen |
Uh oh!
There was an error while loading. Please reload this page.
Martin Wegner opened SPR-12744 and commented
Since Spring 4.1.5 the DI cannot find my profile activated 'database.dataSource' bean.
My web.xml activates the 'jetty' profile:
And my config looks like:
The '!live' annotated bean must be activated and used.
With Spring 4.1.4 and lower it works.
It is a blocker bug because the whole application does not start.
Affects: 4.1.5
Issue Links:
@Profile
declarations on overloaded@Bean
methodsReferenced from: commits ce085a6, bb5b5d5
The text was updated successfully, but these errors were encountered: