From eb4144eb97aeb056a96f69808fea415cc6368dc5 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 1 Jul 2021 15:39:16 -0700 Subject: [PATCH] Add clarification on when @DevaultValue is used during binding Closes gh-26742 --- .../boot/context/properties/bind/DefaultValue.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java index fbf7ffed2e..a1363161cc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java @@ -25,7 +25,13 @@ import java.lang.annotation.Target; /** * Annotation that can be used to specify the default value when binding to an immutable * property. This annotation can also be used with nested properties to indicate that a - * value should always be bound (rather than binding {@code null}). + * value should always be bound (rather than binding {@code null}). The value from this + * annotation will only be used if the property is not found in the property sources used + * by the {@link Binder}. For example, if the property is present in the + * {@link org.springframework.core.env.Environment} when binding to + * {@link org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties}, + * the default value for the property will not be used even if the property value is + * empty. * * @author Madhura Bhave * @since 2.2.0