Skip to content

Commit e30ae7a

Browse files
committed
Document problem with property binding and Kotlin value classes
Closes gh-41693
1 parent a89ae3f commit e30ae7a

File tree

1 file changed

+5
-1
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/features

1 file changed

+5
-1
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/kotlin.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TIP: `org.jetbrains.kotlinx:kotlinx-coroutines-reactor` dependency is provided b
108108

109109
[[features.kotlin.configuration-properties]]
110110
=== @ConfigurationProperties
111-
`@ConfigurationProperties` when used in combination with <<features#features.external-config.typesafe-configuration-properties.constructor-binding,constructor binding>> supports classes with immutable `val` properties as shown in the following example:
111+
`@ConfigurationProperties` when used in combination with <<features#features.external-config.typesafe-configuration-properties.constructor-binding,constructor binding>> supports data classes with immutable `val` properties as shown in the following example:
112112

113113
[source,kotlin,indent=0,subs="verbatim"]
114114
----
@@ -125,6 +125,10 @@ data class KotlinExampleProperties(
125125
}
126126
----
127127

128+
Due to the limitations of their interoperability with Java, support for value classes is limited.
129+
In particular, relying upon a value class's default value will not work with configuration property binding.
130+
In such cases, a data class should be used instead.
131+
128132
TIP: To generate <<configuration-metadata#appendix.configuration-metadata.annotation-processor,your own metadata>> using the annotation processor, {kotlin-docs}kapt.html[`kapt` should be configured] with the `spring-boot-configuration-processor` dependency.
129133
Note that some features (such as detecting the default value or deprecated items) are not working due to limitations in the model kapt provides.
130134

0 commit comments

Comments
 (0)