Skip to content

Commit eb4144e

Browse files
committed
Add clarification on when @DevaultValue is used during binding
Closes gh-26742
1 parent 44b0bd4 commit eb4144e

File tree

1 file changed

+7
-1
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind

1 file changed

+7
-1
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
/**
2626
* Annotation that can be used to specify the default value when binding to an immutable
2727
* property. This annotation can also be used with nested properties to indicate that a
28-
* value should always be bound (rather than binding {@code null}).
28+
* value should always be bound (rather than binding {@code null}). The value from this
29+
* annotation will only be used if the property is not found in the property sources used
30+
* by the {@link Binder}. For example, if the property is present in the
31+
* {@link org.springframework.core.env.Environment} when binding to
32+
* {@link org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties},
33+
* the default value for the property will not be used even if the property value is
34+
* empty.
2935
*
3036
* @author Madhura Bhave
3137
* @since 2.2.0

0 commit comments

Comments
 (0)