@ -9,6 +9,9 @@ existing libraries written in Java.
@@ -9,6 +9,9 @@ existing libraries written in Java.
The Spring Framework provides first-class support for Kotlin that allows developers to write
Kotlin applications almost as if the Spring Framework was a native Kotlin framework.
Feel free to join the #spring channel of http://slack.kotlinlang.org/[Kotlin Slack] or ask
a question with `spring` and `kotlin` tags on
https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow] if you need support.
@ -17,8 +20,8 @@ Kotlin applications almost as if the Spring Framework was a native Kotlin framew
@@ -17,8 +20,8 @@ Kotlin applications almost as if the Spring Framework was a native Kotlin framew
Spring Framework supports Kotlin 1.1+ and requires
@ -94,7 +97,7 @@ via tooling-friendly annotations declared in the `org.springframework.lang` pack
@@ -94,7 +97,7 @@ via tooling-friendly annotations declared in the `org.springframework.lang` pack
By default, types from Java APIs used in Kotlin are recognized as
https://github.com/Kotlin/KEEP/blob/jsr-305/proposals/jsr-305-custom-nullability-qualifiers.md[Kotlin support for JSR 305 annotations]
https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support[Kotlin support for JSR 305 annotations]
+ Spring nullability annotations provide null-safety for the whole Spring Framework API to Kotlin developers,
with the advantage of dealing with `null` related issues at compile time.
@ -106,15 +109,16 @@ Libraries like Reactor or Spring Data provide null-safe APIs leveraging this fea
@@ -106,15 +109,16 @@ Libraries like Reactor or Spring Data provide null-safe APIs leveraging this fea
The JSR 305 checks can be configured by adding the `-Xjsr305` compiler flag with the following
options: `-Xjsr305={strict|warn|ignore}`.
For kotlin versions 1.1.50+, the default behavior is the same to `-Xjsr305=warn`.
The `strict` value is required to have Spring Framework API full null-safety taken in account
but should be considered experimental since Spring API nullability declaration could evolve
even between minor releases and more checks may be added in the future).
For kotlin versions 1.1+, the default behavior is the same to `-Xjsr305=warn`.
The `strict` value is required to have Spring Framework API null-safety taken in account
in Kotlin types inferred from Spring API but should be used with the knowledge that Spring
API nullability declaration could evolve even between minor releases and more checks may
be added in the future).
[NOTE]
====
Generic type arguments, varargs and array elements nullability are not supported yet,
but should be in an upcoming release, see https://github.com/Kotlin/KEEP/issues/79[this dicussion]
but should be in an upcoming release, see https://github.com/Kotlin/KEEP/issues/79[this discussion]
for up-to-date information.
====
@ -523,8 +527,8 @@ can be customised with configuration beans, like as follows:
@@ -523,8 +527,8 @@ can be customised with configuration beans, like as follows:
However, in Kotlin 1.2+, one will have to write `@RequestMapping("/foo", method = [RequestMethod.GET])`
or `@RequestMapping(path = ["/foo"], method = [RequestMethod.GET])` (square brackets need
to be specified with named array attributes).
A workaround for this specific `method` attribute (the most common one) is to
An alternative for this specific `method` attribute (the most common one) is to
use a shortcut annotation such as `@GetMapping` or `@PostMapping`, etc.
[NOTE]
====
Reminder: If the `@RequestMapping` `method` attribute is not specified,
all HTTP methods will be matched, not only the `GET` methods.
all HTTP methods will be matched, not only the `GET` one.
====
Improving the syntax and consistency of Kotlin annotation array attributes is discussed in
https://youtrack.jetbrains.com/issue/KT-11235[this Kotlin language design issue].
=== Testing
@ -702,11 +703,12 @@ MVC and its annotation-based programming model is a perfectly valid and fully su
@@ -702,11 +703,12 @@ MVC and its annotation-based programming model is a perfectly valid and fully su
[[kotlin-resources-started]]
[[kotlin-resources]]
== Resources
* http://kotlinlang.org/docs/reference/[Kotlin language reference]
* http://slack.kotlinlang.org/[Kotlin Slack] (with a dedicated #spring channel)
* https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow with `spring` and `kotlin` tags]
* https://try.kotlinlang.org/[Try Kotlin in your browser]
* https://blog.jetbrains.com/kotlin/[Kotlin blog]
* https://kotlin.link/[Awesome Kotlin]
@ -729,6 +731,7 @@ MVC and its annotation-based programming model is a perfectly valid and fully su
@@ -729,6 +731,7 @@ MVC and its annotation-based programming model is a perfectly valid and fully su
* https://github.com/sdeleuze/spring-kotlin-fullstack[spring-kotlin-fullstack]: WebFlux Kotlin fullstack example with Kotlin2js for frontend instead of JavaScript or TypeScript
* https://github.com/spring-petclinic/spring-petclinic-kotlin[spring-petclinic-kotlin]: Kotlin version of the Spring PetClinic Sample Application
* https://github.com/sdeleuze/spring-kotlin-deepdive[spring-kotlin-deepdive]: a step by step migration for Boot 1.0 + Java to Boot 2.0 + Kotlin
@ -752,26 +755,22 @@ Here is a list of pending issues related to Spring + Kotlin support.
@@ -752,26 +755,22 @@ Here is a list of pending issues related to Spring + Kotlin support.