-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
ConfigurationProperties beans should be embeddable #42179
Comments
That's the expected behavior as the scope of these are quite different, even in the scope of an application. AFAIK flagging the four fields in I don't really understand why you'd want the prefix to be repeated. |
If
Using It would be nice for Spring Boot to handle the following case:
|
Thanks, it was far from obvious to me that you expected auto-configuration to apply to those. I think the embedded bits is by far a detail compared to having auto-configuration deal with multiple beans of the same type. I am going to close this in favor of #15732 where that feature is discussed at length. |
Motivation
ConfigurationProperties
has many of out-of-box implementations for different technologies, like Apache Kafka, DataSource, JMS, etc.Software Developers often combine a bunch of technologies in a single application with results in several
@ConfigurationProperties
Spring Beans one for each in use technologies.Proposal
It would be great to have a way to combine all the
@ConfigurationProperties
beans in a single@ConfigurationProperties
Spring Bean and keep all the auto-configuration abilities at the same timeExample
There is an
application.properties
file with two Apache Kafka Clusters and two Data Sources:It would be nice to be able to define a bean that reads all the properties into a single bean like this:
So then I can inject this single bean instead of a bunch of
@ConfigurationProperties
beans:Alternatives
It's possible to manually construct such an bean like:
@Configuration
bean that construct a bean for the app's properties:The text was updated successfully, but these errors were encountered: