Skip to content

Commit fec0e94

Browse files
committed
Merge branch '4.0.x'
Closes gh-49852
2 parents 7c28c39 + 3c16fe6 commit fec0e94

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/external-config.adoc‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ TIP: To use a reserved keyword in the name of a property, such as `my.service.im
881881

882882

883883
[[features.external-config.typesafe-configuration-properties.constructor-binding.default-values]]
884-
==== Default Values
884+
==== @DefaultValue and Binding
885885

886886
Default values can be specified using javadoc:org.springframework.boot.context.properties.bind.DefaultValue[format=annotation] on constructor parameters and record components.
887887
The conversion service will be applied to coerce the annotation's javadoc:java.lang.String[] value to the target type of a missing property.
@@ -948,6 +948,18 @@ TIP: When using Kotlin, you will need to declare the `username` and `password` p
948948

949949

950950

951+
[[features.external-config.typesafe-configuration-properties.default-values]]
952+
=== Default Values
953+
954+
Default Values defined in configuration properties are not reflected in the javadoc:org.springframework.core.env.Environment[].
955+
In the examples above, the `enabled` property of `MyProperties` bound to `my.service` is `false` by default.
956+
957+
However, `my.service.enabled` is not available in the `Environment` with a value of `false` if no such property is set by the user.
958+
Concretely, this prevents you to use `@Value(${"my.service.enabled"})` or `my.service.enabled` as a placeholder in configuration properties without explicitly providing a default.
959+
If you need to query the javadoc:org.springframework.core.env.Environment[] for that property, for instance in a javadoc:org.springframework.context.annotation.Condition[] implementation, the default needs to be provided as well.
960+
961+
962+
951963
[[features.external-config.typesafe-configuration-properties.enabling-annotated-types]]
952964
=== Enabling @ConfigurationProperties-annotated Types
953965

0 commit comments

Comments
 (0)