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>()`
233
-
is a shortcut for `applicationContext.getBean(Routes::class.java)`.
229
+
NOTE: This DSL is programmatic, meaning it allows custom registration logic of beans
230
+
through an `if` expression, a `for` loop, or any other Kotlin constructs.
234
231
235
232
You can then use this `beans()` function to register beans on the application context,
236
233
as the following example shows:
237
234
238
235
[source,kotlin,indent=0]
239
236
----
240
237
val context = GenericApplicationContext().apply {
241
-
beans().initialize(this)
238
+
myBeans.initialize(this)
242
239
refresh()
243
240
}
244
241
----
245
242
246
-
NOTE: This DSL is programmatic, meaning it allows custom registration logic of beans
247
-
through an `if` expression, a `for` loop, or any other Kotlin constructs.
248
243
249
-
See https://github.com/sdeleuze/spring-kotlin-functional/blob/master/src/main/kotlin/functional/Beans.kt[spring-kotlin-functional beans declaration]
250
-
for a concrete example.
244
+
See https://github.com/sdeleuze/spring-kotlin-functional[spring-kotlin-functional beans declaration] for a concrete example.
251
245
252
-
NOTE: Spring Boot is based on Java configuration and
246
+
NOTE: Spring Boot is based on JavaConfig and
253
247
https://github.com/spring-projects/spring-boot/issues/8115[does not yet provide specific support for functional bean definition],
254
248
but you can experimentally use functional bean definitions through Spring Boot's `ApplicationContextInitializer` support.
255
249
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]
@@ -266,8 +260,8 @@ for more details and up-to-date information.
Spring WebFlux is recommended if you want to create applications that will deal with latency,
671
-
long-lived connections, o streaming scenarios or if you want to use the web functional
694
+
long-lived connections, streaming scenarios or if you want to use the web functional
672
695
Kotlin DSL.
673
696
674
697
For other use cases, especially if you are using blocking technologies such as JPA, Spring
675
-
MVC and its annotation-based programming model is a perfectly valid and fully supported choice.
698
+
MVC and its annotation-based programming model is the recommended choice.
676
699
677
700
678
701
@@ -690,27 +713,6 @@ Kotlin and the Spring Framework:
690
713
* https://kotlin.link/[Awesome Kotlin]
691
714
692
715
693
-
694
-
=== Tutorials
695
-
696
-
We recommend the following tutorials:
697
-
698
-
* https://spring.io/guides/tutorials/spring-boot-kotlin/[Building web applications with Spring Boot and Kotlin]
699
-
* https://kotlinlang.org/docs/tutorials/spring-boot-restful.html[Creating a RESTful Web Service with Spring Boot]
700
-
701
-
702
-
703
-
=== Blog posts
704
-
705
-
The following blog posts provide further details:
706
-
707
-
* https://spring.io/blog/2016/02/15/developing-spring-boot-applications-with-kotlin[Developing Spring Boot applications with Kotlin]
708
-
* 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]
709
-
* https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0[Introducing Kotlin support in Spring Framework 5.0]
710
-
* https://spring.io/blog/2017/08/01/spring-framework-5-kotlin-apis-the-functional-way[Spring Framework 5 Kotlin APIs, the functional way]
711
-
712
-
713
-
714
716
=== Examples
715
717
716
718
The following Github projects offer examples that you can learn from and possibly even extend:
@@ -721,6 +723,7 @@ The following Github projects offer examples that you can learn from and possibl
721
723
* https://github.com/sdeleuze/spring-kotlin-fullstack[spring-kotlin-fullstack]: WebFlux Kotlin fullstack example with Kotlin2js for frontend instead of JavaScript or TypeScript
722
724
* https://github.com/spring-petclinic/spring-petclinic-kotlin[spring-petclinic-kotlin]: Kotlin version of the Spring PetClinic Sample Application
723
725
* https://github.com/sdeleuze/spring-kotlin-deepdive[spring-kotlin-deepdive]: A step-by-step migration guide for Boot 1.0 and Java to Boot 2.0 and Kotlin
726
+
* https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-kotlin-samples/spring-cloud-gcp-kotlin-app-sample[spring-cloud-gcp-kotlin-app-sample]: Spring Boot with Google Cloud Platform Integrations
724
727
725
728
726
729
@@ -729,22 +732,19 @@ The following Github projects offer examples that you can learn from and possibl
729
732
The following list categorizes the pending issues related to Spring and Kotlin support:
730
733
731
734
* Spring Framework
732
-
** https://jira.spring.io/browse/SPR-16057[Unable to use WebTestClient with mock server in Kotlin]
733
-
** https://jira.spring.io/browse/SPR-15942[Support null-safety at generics, varargs and array elements level]
734
-
** https://jira.spring.io/browse/SPR-15413[Add support for Kotlin coroutines]
735
+
** https://github.com/spring-projects/spring-framework/issues/20606[Unable to use WebTestClient with mock server in Kotlin]
736
+
** https://github.com/spring-projects/spring-framework/issues/20496[Support null-safety at generics, varargs and array elements level]
737
+
** https://github.com/spring-projects/spring-framework/issues/19975[Add support for Kotlin coroutines]
735
738
* Spring Boot
736
739
** https://github.com/spring-projects/spring-boot/issues/8762[Allow `@ConfigurationProperties` binding for immutable POJOs]
737
-
** https://github.com/spring-projects/spring-boot/issues/1254[Allow `@ConfigurationProperties` binding on interfaces]
738
740
** https://github.com/spring-projects/spring-boot/issues/8115[Expose the functional bean registration API via `SpringApplication`]
739
741
** https://github.com/spring-projects/spring-boot/issues/10712[Add null-safety annotations on Spring Boot APIs]
740
742
** https://github.com/spring-projects/spring-boot/issues/9486[Use Kotlin's bom to provide dependency management for Kotlin]
741
743
* Kotlin
742
744
** https://youtrack.jetbrains.com/issue/KT-6380[Parent issue for Spring Framework support]
743
745
** https://youtrack.jetbrains.com/issue/KT-5464[Kotlin requires type inference where Java doesn't]
0 commit comments