Talk

Spring + Kotlin = Modern + Reactive + Productive
Conference (INTERMEDIATE level)
Room 5
Score 0.14
Score 0.17
Score 0.17
Score 0.18
The match becomes increasingly accurate as the similarity score approaches zero.

The combination of Spring and Kotlin is a winning combo for building modern, reactive, and productive servers.  This talk will walk through how Spring & Kotlin fit together with coroutines, R2DBC, Testcontainers, and Kotlin/JS for the web UI.  Come for Kotlin, stay for the ASCII art!

James Ward
Google

Professional software developer since 1997, with much of that time spent helping developers build software that doesn't suck. A Typed Pure Functional Programming zealot who often compromises on his ideals to just get stuff done. Currently the Kotlin Product Manager at Google.

Josh Long
VMware

Josh (@starbuxman) has been the first Spring Developer Advocate since 2010. Josh is a Java Champion, author of 6 books (including O'Reilly's "Cloud Native Java: Designing Resilient Systems with Spring Boot, Spring Cloud, and Cloud Foundry" and "Reactive Spring") and numerous best-selling video training (including "Building Microservices with Spring Boot Livelessons" with Spring Boot co-founder Phil Webb), and an open-source contributor (Spring Boot, Spring Integration, Spring Cloud, Activiti and Vaadin, etc), a podcaster ("A Bootiful Podcast") and a YouTuber.

Generated Summary
WARNING: This summary was generated using GPT based on the transcript, as a result spelling mistakes and more importantly hallucinations can be present.

Using Kotlin, Spring and Gradle to Create a Web Application
James Ward and Josh Long Discuss Their Love for Kotlin
James Ward and Josh Long discussed their love for the pliable language Kotlin and its many uses. They talked about the upcoming Spring Framework release that supports the AOT compiler and looked at some code examples. They also took a selfie to commemorate their reunion after three years.
The Spring Framework 5 Release
In September 2017, the Spring Framework 5 was released. It brought many opportunities such as a new Baseline JRE requirement for Java 17 and updated Jakarta APIs. However, it is not yet complete. The suggested software for building a new piece of software is called AOT and is an old version of Spring Boot from a week and a half ago. It requires Postgres, Reactive Web Support, R2DBC and Test Containers as dependencies. Furthermore, it is important to use Java 17 as Spring Boot 3 assumes this baseline.
Java 17 is an Upgrade from Java 8
In the future, by 2027, when people are writing code against Java 29, using Java 17 will look silly so it is recommended to use the latest and greatest version. Java 17 is an upgrade from Java 8 that offers superior speed, robustness, syntax richness, performance, and operations friendliness. It is recommended to use Java 17 instead of Java 8 in 2022.
Connecting to a Database with Spring and Kotlin
To build an application that talks to a database, a schema must first be created and then a data source must be connected. Spring and Kotlin work well together and allow for the creation of a repository by extending Coroutine Crud Repository. Spring Data provides a variety of options for connecting to databases, including blocking options based on JDBC and reactive options based on R2DBC. When using Java, the ReactiveCrudRepository provides access to Reactor APIs. When using Kotlin, Co-routines can be used on top of the R2DBC repository, allowing access to more powerful features such as creating an HTTP router and functional router. This allows developers to take advantage of the deep integrations between Spring and Kotlin.
Using Kotlin to Create a Non-Blocking Back Pressure API
Kotlin is a great addition to the Spring Ecosystem, offering a new way to write code without using Lombok. This example shows how to build an HTTP handler that returns customer data, using Kotlin's suspending functions and extension functions. It also demonstrates how to create a flow of customers, and save them into the repository. The whole process is non-blocking and easy to understand. This is a demonstration of using Kotlin's Coroutines and Spring to create a non-blocking back pressure API. It shows how to use the suspend function and run blocking to wrap the code in a coroutine context. JetBrains and Visual Studio Code are popular IDE's used for this type of development. The demo also shows how to use streams and flows to connect the database to the HTTP request.
The Benefits of Using the Gravian Reachability Repository
The demo ends with an HTTP request being made and the result being successful. Spring Boot 3 provides a new Ahead-of-Time engine which allows for metadata to be added to code at compile time. Gravian is a technology that scans code for types used and performs static analysis to optimize the application. It requires configuration for dynamic activities such as loading from a class path, serialization, reflection, and proxies. Spring Boot 3 tries to provide this configuration, but third-party libraries may require additional configuration. The Gravian Reachability Repository provides these config files to help optimize applications. Spring Boot is the first framework to take advantage of a repository for configuration files, which is a community effort to build out this configuration as individual projects do not want to be responsible for maintaining them. This repository is meant to get smaller over time as the config files get moved back into respective projects. The important benefits of using the repository are faster startup time and lower memory usage, which can be especially beneficial when running in a cloud context.
Conclusion
This talk demonstrated the advantages of using Kotlin, Spring and Gradle to create a web application that visualizes data from a REST service. It also showed how to use test containers to add tests to an application, and how to use a Mac computer to share code with a Linux user. Furthermore, the speaker demonstrated how to build a UI for an Android app using Compose in just two minutes. In conclusion, this talk showed how to use Kotlin, Spring, and Gradle to create an efficient and effective web application.
You can also ask questions on the complete talk using Devoxx Insights