diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 5383cc88c31..c0e71127a48 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -7614,35 +7614,44 @@ In order to avoid mixing different versions of Kotlin dependencies on the classp With Maven, the Kotlin version can be customized via the `kotlin.version` property and plugin management is provided for `kotlin-maven-plugin`. With Gradle, the Spring Boot plugin automatically aligns the `kotlin.version` with the version of the Kotlin plugin. +Spring Boot also manages the version of Coroutines dependencies by importing Kotlin +Coroutines BOM, which can be customized via the `kotlin-coroutines.version` property. + +TIP: `org.jetbrains.kotlinx:kotlinx-coroutines-reactor` dependency is provided by default +if one bootstraps a Kotlin project with at least one Reactive dependency on https://start.spring.io/#!language=kotlin[start.spring.io]. [[boot-features-kotlin-configuration-properties]] === `@ConfigurationProperties` -`@ConfigurationProperties` supports classes with immutable `val` properties as shown in the following example: +`@ConfigurationProperties` when used in combination with `@ConstructorBinding` (see the +<> for more details) +supports classes with immutable `val` properties as shown in the following example: [source,kotlin,indent=0] ---- @ConfigurationProperties("example.kotlin") +@ConstructorBinding data class KotlinExampleProperties( val name: String, val description: String, - val myService: MyService -) + val myService: MyService) { -data class MyService( - val apiToken: String, - val uri: URI -) + data class MyService( + val apiToken: String, + val uri: URI + ) +} ---- TIP: To generate <> using the annotation processor, {kotlin-docs}kapt.html[`kapt` should be configured] with the `spring-boot-configuration-processor` dependency. -Note that some features (such as detecting the default value or deperecated items) are not working due to limitations in the model kapt provides. +Note that some features (such as detecting the default value or deprecated items) are not working due to limitations in the model kapt provides. [[boot-features-kotlin-testing]] === Testing -While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 is recommended. +While it is possible to use JUnit 4 to test Kotlin code, JUnit 5 now provided by default +with Spring Boot is recommended. JUnit 5 enables a test class to be instantiated once and reused for all of the class's tests. This makes it possible to use `@BeforeClass` and `@AfterClass` annotations on non-static methods, which is a good fit for Kotlin. @@ -7683,6 +7692,7 @@ If you need the `Mockk` equivalent of the Mockito specific <