-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Configuration Processor should use the constructor as a source only with @ConstructorBinding #17035
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
@bdemers that setup is slightly odd in the first place. If you use
In the 2.2 line we've started to support constructor binding so it's not only about metadata-generation. That constructor is now flagged as the preferred way to create the bean and bind its content from the environment, see this part of the 2.2 doc and it won't inject another bean but rather try to resolve If you really need to get this, I'll use a setter injection for Having said all that, |
@snicoll I wouldn't read that tip, as don't do it, but more be careful if you are doing this. Good catch on the The metadata generated was not effected by this change (both in 2.1.5 and 2.2.0.M3) Thanks for the heads up on the Thanks again! |
* work around configuration processor issue spring-projects/spring-boot#17035 * Adjust AutoConfig tests to apply EnvironmentPostProcessor when context is loaded.
* work around configuration processor issue spring-projects/spring-boot#17035 * Adjust AutoConfig tests to apply EnvironmentPostProcessor when context is loaded.
Configuration properties are scanned now and their lifecycle is such that if a constructor is present we use it to bind from the environment. That’s why the nested one shows up btw as it is now considered an explicit property. You are correct about the note and doing something we don’t recommend and for which there is a note against is the reason we think it is acceptable to change in a feature release. If you really need to do this, create the bean yourself (using @bean) and don’t use classpath scanning/registration per class. |
* work around configuration processor issue spring-projects/spring-boot#17035 * Adjust AutoConfig tests to apply EnvironmentPostProcessor when context is loaded.
We've added a dedicated |
Uh oh!
There was an error while loading. Please reload this page.
Starting with 2.2.0.M3
spring-boot-configuration-processor
generates an incorrectspring-configuration-metadata.json
when configuration property class contains another autowired ConfigurationProperties.For example:
This works in 2.1.5.RELEASE and 2.2.0.M1.
Full example: https://github.com/bdemers/spring-config-problem
Running this example with M2 or M3 creates metadata:
expected (and 2.1.5.RELEASE output):
In this case the property
a-string-value
is missing from the M3 version.A work around (not fully tested), is to add a default constructor the the config properties object:
The text was updated successfully, but these errors were encountered: