-
Notifications
You must be signed in to change notification settings - Fork 37.9k
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
@Bean overriding does not pick up metadata from most specific method [SPR-10992] #15620
Comments
Jose Luis Martin commented When overriding a I guess that problem start in ConfigurationClassParser
That result on overriden method added to CongurationClass.beanMethods. I guess that it could be fixed checking if the beanMethod was already added from a superclass in ConfigurationClass.addBeanMethod()
If makes sense to completely ignore overriden bean methods in a ConfigurationClass. |
Jose Luis Martin commented I have done a pull request to fix the issue. |
Jose Luis Martin commented After reading #15616, I don't see now a very good idea to hide bean methods to ConfigurationClass.validate() so I update the proposed fix to filter bean method elegible for bean definitions in a separate method. |
Phil Webb commented If the beans that you are dealing with are all created by // ...
@Bean
public Object bean() {
doInit(); // usually would be a method that returns a bean
// ....
return "overriden";
} |
Benoit Lacelle commented Thanks Phil, I see hoy do do this in the dependeny is in the same |
Phil Webb commented You can BTW: I think your original bug report is still valid, this just might let you work around it. |
Benoit Lacelle commented I see. Nice! I've workarounded it by extending the bean with a more classic override, and put the
I would prefer your solution but this issue is in the same context as #15616: the doInit method requires an |
Juergen Hoeller commented I've revised the This works for regular overriding as well as for overloading in subclasses, where the metadata is now always being taken from the Juergen |
Benoit Lacelle commented Thanks a lot Juergen! |
Benoit Lacelle opened SPR-10992 and commented
While overrding a Javaconfig Bean by extending the original
@Configuration
class, I would like to add a@DependsOn
for the new Bean definition.However, this depends-on seems not to be taken in account. here is a TestCase reproducing my issues:
Is this an expected behavior? If yes, how can I add dependency while overriding a bean?
Affects: 3.2.3
Issue Links:
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: