-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Prevent beans to be instantiated at build-time unless it has been flagged #28838
Comments
Unfortunately, this approach is too restricted for configuration classes or builder-style that gathers a number of dependencies to produce the target bean. An example of such a use case is Rather than restricting the dependencies that one can inject, perhaps we could provide a proxy that would throw an exception if a component attempt to use it. Such proxy would not be created for classes that are flagged (maybe with an annotation). A list of types or predicates can also be provided. |
After a review, we're not sure if we want to introduce this. We should see how far we go with the integration of the portfolio and how common such problem arises. We could argue that we may want to do the opposite in the end (flag a bean that has to be instantiated but we want to pass a proxy rather than actual instantiating it). I've moved the issue to the backlog as we're not committed to implement it for the next milestone. |
Let's close this one for now. We can reopen if necessary. |
It's becoming more apparent that certain beans will have to be instantiated at build time (typically to introspect the outcome of something that could have been overridden by the user). We want to make sure that these are limited and that trying to resolve too much dependencies will fail fast.
One idea was to adapt
ContextAnnotationAutowireCandidateResolver
to only resolve low-level dependencies, such asApplicationContext
,BeanFactory
, and the like.The text was updated successfully, but these errors were encountered: