Skip to content

Commit 466699b

Browse files
committed
Polishing
Issue: SPR-15659
1 parent a8f1028 commit 466699b

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/docs/asciidoc/kotlin.adoc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ https://kotlinlang.org[Kotlin] is a statically-typed language targeting the JVM
1111
code while providing a very good https://kotlinlang.org/docs/reference/java-interop.html[interoperability] with libraries
1212
written in Java.
1313

14-
Spring Framework 5 introduces first-class support for Kotlin in order to allow developers to write Spring + Kotlin
14+
Spring Framework 5 introduces first-class support for Kotlin and allows developers to write Spring + Kotlin
1515
applications almost like if Spring Framework was a native Kotlin framework.
1616

1717
== Requirements ==
@@ -23,7 +23,7 @@ and https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-reflect[`k
2323
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on
2424
https://start.spring.io/#!language=kotlin[start.spring.io].
2525

26-
== Kotlin extensions for Spring API
26+
== Extensions
2727

2828
Thanks to its great https://kotlinlang.org/docs/reference/java-interop.html[Java interoperability]
2929
and to https://kotlinlang.org/docs/reference/extensions.html[Kotlin extensions], Spring
@@ -73,7 +73,7 @@ Other libraries like Reactor or Spring Data also provide Kotlin extensions for t
7373
in order to allow a better Kotlin development experience.
7474
====
7575

76-
== Null-safety of Spring API
76+
== Null-safety
7777

7878
One of Kotlin's key features is https://kotlinlang.org/docs/reference/null-safety.html[null-safety]
7979
which allows to deal with `null` values at compile time rather than bumping into the famous
@@ -115,7 +115,7 @@ Other libraries like Reactor or Spring Data leverage these annotations to provid
115115
null-safe APIs for Kotlin developers.
116116
====
117117

118-
== Support for Kotlin classes
118+
== Classes
119119

120120
Spring Framework 5 now supports various Kotlin constructs like instantiating Kotlin classes
121121
via primary constructors, immutable classes data binding and function optional parameters
@@ -131,7 +131,7 @@ Kotlin module.
131131
As of Spring Boot 2.0, Jackson Kotlin module is automatically provided via the JSON starter.
132132
====
133133

134-
== Leveraging null-safety in Spring annotations
134+
== Annotations
135135

136136
Spring Framework also takes advantage of https://kotlinlang.org/docs/reference/null-safety.html[Kotlin null-safety]
137137
to determine if an HTTP parameter is required without having to define explicitly the `required` attribute.
@@ -144,11 +144,11 @@ to know if a bean is required or not. `@Autowired lateinit var foo: Foo` implies
144144
of type `Foo` must be registered in the application context while `@Autowired lateinit var foo: Foo?`
145145
won’t raise an error if such bean does not exist.
146146

147-
== Spring WebFlux functional DSL
147+
== WebFlux functional DSL
148148

149149
Spring Framework 5 comes with a
150150
{doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/-router-function-dsl/[Kotlin routing DSL]
151-
that allows you to leverage the <<webflux-fn,WebFlux functional API] with clean and idiomatic Kotlin code:
151+
that allows you to leverage the <<reactive-web#webflux-fn,WebFlux functional API>> with clean and idiomatic Kotlin code:
152152

153153
[source,kotlin]
154154
----
@@ -278,7 +278,7 @@ see https://jira.spring.io/browse/SPR-13779[SPR-13779] and https://github.com/sp
278278
for more details and up to date informations.
279279
====
280280

281-
== Kotlin Script based templates
281+
== Kotlin Script templates
282282

283283
As of version 4.3, Spring Framework provides a
284284
http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/view/script/ScriptTemplateView.html[ScriptTemplateView]
@@ -319,10 +319,10 @@ Boot 2 project on https://start.spring.io/#!language=kotlin[start.spring.io].
319319
It is also possible to create a standalone WebFlux project as described in
320320
https://spring.io/blog/2017/08/01/spring-framework-5-kotlin-apis-the-functional-way[this blog post].
321321

322-
=== Choose your web flavor
322+
=== Choosing your web flavor
323323

324-
Spring Framework now comes with 2 different web stacks: <<web.adoc,Spring MVC>> and
325-
<<reactive-web.adoc,Spring WebFlux>>.
324+
Spring Framework now comes with 2 different web stacks: <<web#mvc,Spring MVC>> and
325+
<<reactive-web#spring-web-reactive,Spring WebFlux>>.
326326

327327
Spring WebFlux is recommended if you want to create applications that will deal with latency,
328328
long-lived connections, streaming scenarios or simply if you want to use the web functional
@@ -331,7 +331,7 @@ Kotlin DSL.
331331
For other use cases, Spring MVC and its annotation-based programming model is a perfectly
332332
valid and fully supported choice.
333333

334-
=== Classes and member functions final by default
334+
=== Final by default
335335

336336
By default, https://discuss.kotlinlang.org/t/classes-final-by-default/166[all classes in Kotlin are `final`].
337337
The `open` modifier on a class is the opposite of Java's `final`: it allows others to
@@ -360,7 +360,7 @@ annotations are meta-annotated with `@Component`.
360360

361361
http://start.spring.io/#!language=kotlin[start.spring.io] enables it by default.
362362

363-
=== What is the recommended way to inject dependencies in Kotlin?
363+
=== Injecting dependencies
364364

365365
Try to favor constructor injection with `val` read-only https://kotlinlang.org/docs/reference/properties.html[properties].
366366

@@ -437,7 +437,7 @@ properties since immutable classes initialized by constructor are not support ye
437437
See https://github.com/spring-projects/spring-boot/issues/8762[this issue] for more details.
438438
====
439439

440-
=== Easy testing Kotlin and JUnit 5
440+
=== Testing
441441

442442
Kotlin allows to specify meaningful test function names betweeen backticks,
443443
and as of JUnit 5 Kotlin test classes can use `@TestInstance(TestInstance.Lifecycle.PER_CLASS)`
@@ -478,7 +478,6 @@ class IntegrationTests {
478478
}
479479
----
480480

481-
482481
=== Resources
483482

484483
* http://kotlinlang.org/docs/reference/[Kotlin language reference]
@@ -504,7 +503,9 @@ class IntegrationTests {
504503

505504
* https://kotlinlang.org/docs/tutorials/spring-boot-restful.html[Creating a RESTful Web Service with Spring Boot]
506505

507-
==== Pending issues to follow
506+
==== Issues
507+
508+
Here is a list of pending issues related to Spring + Kotlin support.
508509

509510
===== Spring Framework
510511

0 commit comments

Comments
 (0)