Allow @ConstructorBinding to be optional
This commit makes @ConstructorBinding optional for a type that has a single parameterized constructor. An @Autowired annotation on any of the constructors indicates that the type should not be constructor bound. Since @ConstructorBinding is now deduced for a single parameterized constructor, the annotation is no longer needed at the type level. Closes gh-23216
This commit is contained in:
@@ -20,10 +20,8 @@ import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
|
||||
@ConstructorBinding
|
||||
@ConfigurationProperties("my.service")
|
||||
public class MyProperties {
|
||||
|
||||
|
||||
@@ -20,10 +20,8 @@ import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
|
||||
@ConstructorBinding
|
||||
@ConfigurationProperties("my.service")
|
||||
public class MyProperties {
|
||||
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.conversion.datasizes.constructorbinding;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.boot.convert.DataSizeUnit;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
|
||||
@ConfigurationProperties("my")
|
||||
@ConstructorBinding
|
||||
public class MyProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
|
||||
@@ -20,12 +20,10 @@ import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.boot.convert.DurationUnit;
|
||||
|
||||
@ConfigurationProperties("my")
|
||||
@ConstructorBinding
|
||||
public class MyProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
|
||||
Reference in New Issue
Block a user