Require annotation signal for constructor binding

Update `@ConfigurationProperties` constructor binding support to only
apply when a `@ConstructorBinding` annotation is present on either the
type or the specific constructor to use.

Prior to this commit we didn't have a good way to tell when constructor
binding should be used vs regular autowiring.

For convenience, an `@ImmutableConfigurationProperties` meta-annotation
has also been added which is composed of `@ConfigurationProperties` and
`@ConstructorBinding`.

Closes gh-18469
This commit is contained in:
Phillip Webb
2019-10-01 17:09:02 -07:00
parent ecf751e7eb
commit e41c5a4327
24 changed files with 584 additions and 143 deletions

View File

@@ -16,16 +16,16 @@
package org.springframework.boot.test.autoconfigure.web.client;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ImmutableConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;
/**
* Example {@link ConfigurationProperties} used to test the use of configuration
* properties scan with sliced test.
* Example {@link ImmutableConfigurationProperties @ImmutableConfigurationProperties} used
* to test the use of configuration properties scan with sliced test.
*
* @author Stephane Nicoll
*/
@ConfigurationProperties("example")
@ImmutableConfigurationProperties("example")
public class ExampleProperties {
private final String name;