Skip to content

sdeleuze/spring-kotlin-deepdive

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Kotlin deepdive

This project is designed to show step by step how to migrate from Java to Kotlin with Spring Boot step by step:

See Spring Kotlin support documentation for more details.

Step 1: Java to Kotlin

Code:

  • No more semicolon at end of lines
  • Type suffixed with colon, as statically typed as Java, optional type inference
  • Show how to configure return type inference hints
  • Short syntax for declaring properties and initializing them from the primary constructor instead of super verbose mostly auto-generated POJO
  • Data classes
  • Data classes
  • Syntax help using naturally immutable classes
  • : instead of extends
  • No need for { } for empty classes / interfaces
  • Optional parameter default value
  • public by the default
  • fun to declare functions
  • Better lambdas: { } last parameter notation, lambda without collect, it default parameter
  • Constructor without new
  • main() top level method
  • Utils class -> Kotlin extensions
  • .getBody() -> .body
  • Meaningful function names between backticks
  • Show copy and paste Java to Kotlin

Build:

  • Dependencies:
    • kotlin-stdlib-jre8
    • kotlin-reflect
    • jackson-module-kotlin
  • Plugins:
    • kotlin
    • kotlin-spring
    • kotlin-noarg
  • Configure to build Java 8 bytecode

Go to step 2: Spring Boot 2

About

A journey from Java to Kotlin with Spring

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •