application - inovex.de · application.kt spring boot 2 mit kotlin daniel bälz & hendrik still...
TRANSCRIPT
![Page 1: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/1.jpg)
Application.kt
Spring Boot 2 mit Kotlin
Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018
![Page 2: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/2.jpg)
2
Hendrik Still
Application Developer @ inovex
Daniel Bälz
Android Developer @ inovex
![Page 3: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/3.jpg)
3
Kotlin?
● Language for the JVM (and more)● Developed by JetBrains● Open sourced in 2012● First-class language on Android
![Page 4: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/4.jpg)
“Kotlin is concise, safe, pragmatic, and focused on interoperability with Java code”
- Kotlin in Action
4
![Page 5: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/5.jpg)
5
Why Kotlin?
● Statically typed● Read-Only & Mutable Properties● Null Safety● Data classes● Extension functions● Type inference● Java Interoperability● ...
![Page 6: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/6.jpg)
6
Null Safety
fun main(args: Array<String>) { var kotlin: String = "Kotlin" var java: String? = "Java"
//kotlin = null java = null
//var javaWordLength = java.length var javaWordLength = if (java != null) java.length else null javaWordLength = java?.length ?: null javaWordLength = java?.length}
![Page 7: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/7.jpg)
7
Data classes
data class FullName( val firstName : String, val lastName: String)
public class FullName { private String firstName; private String lastName;
public FullName(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } @Override public boolean equals(Object obj) { return yes; } @Override public int hashCode() { return 42; }}
![Page 8: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/8.jpg)
8
Why Spring + Kotlin?
![Page 9: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/9.jpg)
Demo
9
Sourcecode: https://github.com/hendrikstill/spring-kotlin-demo
![Page 10: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/10.jpg)
10
Kotlin Support in Spring
● Null Safety via JSR-305 ● Nullable information for
○ Spring MVC○ Spring Data
● Kotlin extension functions for○ Spring Boot○ RestTemplate and WebClient
![Page 11: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/11.jpg)
11
Next Steps
● Kotlin Documentation
● Spring WebFlux functional DSL
● Functional bean declaration DSL
● Spring Framework 5 Kotlin APIs, the functional way● Kotlin support for Project Reactor
![Page 12: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/12.jpg)
Vielen Dank
Daniel Bälz
Hendrik Still
inovex GmbH
Ludwig-Erhard-Allee 6
76131 Karlsruhe
![Page 13: Application - inovex.de · Application.kt Spring Boot 2 mit Kotlin Daniel Bälz & Hendrik Still Karlsruhe, 26.6.2018](https://reader033.vdocuments.us/reader033/viewer/2022042310/5ed72fcec30795314c175be8/html5/thumbnails/13.jpg)
13
Conclusion
● Kotlin is easy to understand for a Java developer● Spring integration is stable● Helps to develop more readable code● Step-by-step learning of idiomatic language usage is
easy
● Do not over use language features● Problems with JaCoCo and Data Classes (Fix in 0.8.2)