You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the preceding example, `bean<Routes>()` uses autowiring by constructor, and `ref<Routes>()`
243
-
is a shortcut for `applicationContext.getBean(Routes::class.java)`.
239
+
NOTE: This DSL is programmatic, meaning it allows custom registration logic of beans
240
+
through an `if` expression, a `for` loop, or any other Kotlin constructs.
244
241
245
242
You can then use this `beans()` function to register beans on the application context,
246
243
as the following example shows:
@@ -249,19 +246,16 @@ as the following example shows:
249
246
[source,kotlin,indent=0]
250
247
----
251
248
val context = GenericApplicationContext().apply {
252
-
beans().initialize(this)
249
+
myBeans.initialize(this)
253
250
refresh()
254
251
}
255
252
----
256
253
====
257
254
258
-
NOTE: This DSL is programmatic, meaning it allows custom registration logic of beans
259
-
through an `if` expression, a `for` loop, or any other Kotlin constructs.
260
255
261
-
See https://github.com/sdeleuze/spring-kotlin-functional/blob/master/src/main/kotlin/functional/Beans.kt[spring-kotlin-functional beans declaration]
262
-
for a concrete example.
256
+
See https://github.com/sdeleuze/spring-kotlin-functional[spring-kotlin-functional beans declaration] for a concrete example.
263
257
264
-
NOTE: Spring Boot is based on Java configuration and
258
+
NOTE: Spring Boot is based on JavaConfig and
265
259
https://github.com/spring-projects/spring-boot/issues/8115[does not yet provide specific support for functional bean definition],
266
260
but you can experimentally use functional bean definitions through Spring Boot's `ApplicationContextInitializer` support.
267
261
See https://stackoverflow.com/questions/45935931/how-to-use-functional-bean-definition-kotlin-dsl-with-spring-boot-and-spring-w/46033685#46033685[this Stack Overflow answer]
@@ -278,8 +272,8 @@ for more details and up-to-date information.
Spring WebFlux is recommended if you want to create applications that will deal with latency,
705
-
long-lived connections, o streaming scenarios or if you want to use the web functional
728
+
long-lived connections, streaming scenarios or if you want to use the web functional
706
729
Kotlin DSL.
707
730
708
731
For other use cases, especially if you are using blocking technologies such as JPA, Spring
709
-
MVC and its annotation-based programming model is a perfectly valid and fully supported choice.
732
+
MVC and its annotation-based programming model is the recommended choice.
710
733
711
734
712
735
@@ -724,27 +747,6 @@ Kotlin and the Spring Framework:
724
747
* https://kotlin.link/[Awesome Kotlin]
725
748
726
749
727
-
728
-
=== Tutorials
729
-
730
-
We recommend the following tutorials:
731
-
732
-
* https://spring.io/guides/tutorials/spring-boot-kotlin/[Building web applications with Spring Boot and Kotlin]
733
-
* https://kotlinlang.org/docs/tutorials/spring-boot-restful.html[Creating a RESTful Web Service with Spring Boot]
734
-
735
-
736
-
737
-
=== Blog posts
738
-
739
-
The following blog posts provide further details:
740
-
741
-
* https://spring.io/blog/2016/02/15/developing-spring-boot-applications-with-kotlin[Developing Spring Boot applications with Kotlin]
742
-
* https://spring.io/blog/2016/03/20/a-geospatial-messenger-with-kotlin-spring-boot-and-postgresql[A Geospatial Messenger with Kotlin, Spring Boot and PostgreSQL]
743
-
* https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0[Introducing Kotlin support in Spring Framework 5.0]
744
-
* https://spring.io/blog/2017/08/01/spring-framework-5-kotlin-apis-the-functional-way[Spring Framework 5 Kotlin APIs, the functional way]
745
-
746
-
747
-
748
750
=== Examples
749
751
750
752
The following Github projects offer examples that you can learn from and possibly even extend:
@@ -764,22 +766,19 @@ The following Github projects offer examples that you can learn from and possibl
764
766
The following list categorizes the pending issues related to Spring and Kotlin support:
765
767
766
768
* Spring Framework
767
-
** https://jira.spring.io/browse/SPR-16057[Unable to use WebTestClient with mock server in Kotlin]
768
-
** https://jira.spring.io/browse/SPR-15942[Support null-safety at generics, varargs and array elements level]
769
-
** https://jira.spring.io/browse/SPR-15413[Add support for Kotlin coroutines]
769
+
** https://github.com/spring-projects/spring-framework/issues/20606[Unable to use WebTestClient with mock server in Kotlin]
770
+
** https://github.com/spring-projects/spring-framework/issues/20496[Support null-safety at generics, varargs and array elements level]
771
+
** https://github.com/spring-projects/spring-framework/issues/19975[Add support for Kotlin coroutines]
770
772
* Spring Boot
771
773
** https://github.com/spring-projects/spring-boot/issues/8762[Allow `@ConfigurationProperties` binding for immutable POJOs]
772
-
** https://github.com/spring-projects/spring-boot/issues/1254[Allow `@ConfigurationProperties` binding on interfaces]
773
774
** https://github.com/spring-projects/spring-boot/issues/8115[Expose the functional bean registration API via `SpringApplication`]
774
775
** https://github.com/spring-projects/spring-boot/issues/10712[Add null-safety annotations on Spring Boot APIs]
775
776
** https://github.com/spring-projects/spring-boot/issues/9486[Use Kotlin's bom to provide dependency management for Kotlin]
776
777
* Kotlin
777
778
** https://youtrack.jetbrains.com/issue/KT-6380[Parent issue for Spring Framework support]
778
779
** https://youtrack.jetbrains.com/issue/KT-5464[Kotlin requires type inference where Java doesn't]
0 commit comments