Skip to content

Commit

Permalink
Clarify requirements for -parameters and configuration properties
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Apr 3, 2024
1 parent 60d2b3e commit 6df6e5f
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ Spring Boot provides an alternative method of working with properties that lets

TIP: See also the <<features#features.external-config.typesafe-configuration-properties.vs-value-annotation,differences between `@Value` and type-safe configuration properties>>.

NOTE: To use type-safe configuration properties the class must be compiled with `-parameters`.
This will happen automatically if you use Spring Boot's Gradle plugin or if you use Maven and `spring-boot-starter-parent`.


[[features.external-config.typesafe-configuration-properties.java-bean-binding]]
Expand Down Expand Up @@ -742,9 +744,6 @@ include::code:nonnull/MyProperties[tag=*]
NOTE: To use constructor binding the class must be enabled using `@EnableConfigurationProperties` or configuration property scanning.
You cannot use constructor binding with beans that are created by the regular Spring mechanisms (for example `@Component` beans, beans created by using `@Bean` methods or beans loaded by using `@Import`)

NOTE: To use constructor binding in a native image the class must be compiled with `-parameters`.
This will happen automatically if you use Spring Boot's Gradle plugin or if you use Maven and `spring-boot-starter-parent`.

NOTE: The use of `java.util.Optional` with `@ConfigurationProperties` is not recommended as it is primarily intended for use as a return type.
As such, it is not well-suited to configuration property injection.
For consistency with properties of other types, if you do declare an `Optional` property and it has no value, `null` rather than an empty `Optional` will be bound.
Expand Down

0 comments on commit 6df6e5f

Please sign in to comment.