@@ -8638,7 +8638,7 @@ Overflow] if you need support.
86388638
86398639[[boot-features-kotlin-requirements]]
86408640=== Requirements
8641- Spring Boot supports Kotlin 1.2 .x. To use Kotlin, `org.jetbrains.kotlin:kotlin-stdlib` and
8641+ Spring Boot supports Kotlin 1.3 .x. To use Kotlin, `org.jetbrains.kotlin:kotlin-stdlib` and
86428642`org.jetbrains.kotlin:kotlin-reflect` must be present on the classpath. The
86438643`kotlin-stdlib` variants `kotlin-stdlib-jdk7` and `kotlin-stdlib-jdk8` can also be used.
86448644
@@ -8741,16 +8741,8 @@ make it possible to take advantage of Kotlin reified type parameters.
87418741
87428742[[boot-features-kotlin-dependency-management]]
87438743=== Dependency management
8744- In order to avoid mixing different version of Kotlin dependencies on the classpath,
8745- dependency management of the following Kotlin dependencies is provided:
8746-
8747- - `kotlin-reflect`
8748- - `kotlin-runtime`
8749- - `kotlin-stdlib`
8750- - `kotlin-stdlib-jdk7`
8751- - `kotlin-stdlib-jdk8`
8752- - `kotlin-stdlib-jre7`
8753- - `kotlin-stdlib-jre8`
8744+ In order to avoid mixing different versions of Kotlin dependencies on the classpath,
8745+ Spring Boot imports the Kotlin BOM.
87548746
87558747With Maven, the Kotlin version can be customized via the `kotlin.version` property and
87568748plugin management is provided for `kotlin-maven-plugin`. With Gradle, the Spring Boot
@@ -8760,35 +8752,29 @@ plugin automatically aligns the `kotlin.version` with the version of the Kotlin
87608752
87618753[[boot-features-kotlin-configuration-properties]]
87628754=== `@ConfigurationProperties`
8763- `@ConfigurationProperties` currently only works with `lateinit` or nullable `var`
8764- properties (the former is recommended), since immutable classes initialized by
8765- constructors are {github-issues}8762[not yet supported].
8755+ `@ConfigurationProperties` supports classes with immutable `val` properties as shown in
8756+ the following example:
87668757
87678758[source,kotlin,indent=0]
87688759----
87698760@ConfigurationProperties("example.kotlin")
8770- class KotlinExampleProperties {
8771-
8772- lateinit var name: String
8773-
8774- lateinit var description: String
8775-
8776- val myService = MyService()
8777-
8778- class MyService {
8761+ data class KotlinExampleProperties(
8762+ val name: String,
8763+ val description: String,
8764+ val myService: MyService
8765+ )
87798766
8780- lateinit var apiToken: String
8781-
8782- lateinit var uri: URI
8783-
8784- }
8785-
8786- }
8767+ data class MyService(
8768+ val apiToken: String,
8769+ val uri: URI
8770+ )
87878771----
87888772
87898773TIP: To generate <<appendix.adoc#configuration-metadata-annotation-processor,your own
87908774metadata>> using the annotation processor, {kotlin-documentation}kapt.html[`kapt` should
8791- be configured] with the `spring-boot-configuration-processor` dependency.
8775+ be configured] with the `spring-boot-configuration-processor` dependency. Note that some
8776+ features (such as detecting the default value or deperecated items) are not working due
8777+ to limitations in the model kapt provides.
87928778
87938779
87948780[[boot-features-kotlin-testing]]
0 commit comments