Skip to content
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

Support @Bean 'lite' mode when no @Bean methods are declared locally #30462

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented May 10, 2023

ConfigurationClassUtils should check bean methods in super classes also
Fix GH-30449

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 10, 2023
@quaff quaff marked this pull request as draft May 10, 2023 09:30
@quaff quaff marked this pull request as ready for review May 11, 2023 01:20
…te mode

ConfigurationClassUtils should check bean methods in super classes also

Fix spring-projectsGH-30449
@quaff quaff changed the title ConfigurationClassUtils should check bean methods in super classes @Bean methods should be detected even no one declared locally with lite mode May 15, 2023
@quaff
Copy link
Contributor Author

quaff commented May 15, 2023

Test case added, could you review it? @jhoeller @sbrannen

@sbrannen sbrannen changed the title @Bean methods should be detected even no one declared locally with lite mode Support @Bean 'lite' mode when no @Bean methods are declared locally May 15, 2023
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels May 15, 2023
@jhoeller
Copy link
Contributor

This is not within the intentions of our configuration class check which may literally apply to every bean in an application context. Driven by the fact that we're typically introspecting class files in a classpath scan there, not fully resolved classes, we intentionally do not rely on the superclass/interface hierarchy of such beans. We only search for @Bean methods on superclasses and interfaces if there is an indication on the given class to begin with, either a stereotype or local @Bean methods. With the latter local method check, we're just trying to be lenient; in the original version of that code, we insisted on a stereotype for any lite configuration class. I'm afraid we cannot be even more lenient than that when that would incur significant extra parsing cost.

@jhoeller jhoeller closed this May 15, 2023
@sbrannen sbrannen added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 15, 2023
@quaff
Copy link
Contributor Author

quaff commented May 16, 2023

I'm afraid we cannot be even more lenient than that when that would incur significant extra parsing cost.

I don't think it would incur significant extra parsing cost since it's a rare case, at least document should be improved if you insist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@Bean 'lite' mode not supported if @Bean methods are not declared locally
4 participants