O'Reilly logo
live online training icon Live Online training

Kotlin + Spring Boot Essentials

Build Spring Applications Using Kotlin

Ken Kousen

Spring 5 and Spring Boot 2 brought special support for Kotlin to the Spring framework. Anything previously written in Java can now be written in Kotlin, with all the same Spring features and benefits.

This course covers the process of creating, deploying, and maintaining applications and web services written in Spring using the Kotlin programming language. Kotlin is a JVM-based language that features null safety at the compiler level, and is optimized for both performance and safety. Kotlin also makes interoperability with existing Java libraries very easy. For its part, Spring provides special Kotlin extension functions and domain-specific languages that significantly simplify application development and testing.

What you'll learn-and how you can apply it

By the end of this live, hands-on, online course, you’ll understand:

  • How null-safe capabilities in Kotlin eliminate entire classes of potential errors
  • How to take advantage of Kotlin capabilities in Spring
  • Spring development, from basic web applications to restful web services

And you’ll be able to:

  • Build and configure Spring applications written in Kotlin
  • Test and deploy both web apps and restful web services
  • Use Kotlin annotations and extension functions to simplify Spring configuration

This training course is for you because...

  • You are a Java developer who wants to write Spring applications.
  • You are a team member or leader who needs to build and support applications using the Spring framework.
  • You want to take advantage of modern development practices with Kotlin.

Prerequisites

  • Basic familiarity with Java, especially functional features like streams, lambda expressions, and method references.
  • Basic familiarity with Kotlin would be helpful, but is not required.
  • Some exposure to the Spring Framework (such as introduced by the live online training course Getting Started with Spring and Spring Boot) would be helpful, but is not required.

Recommended follow-up:

About your instructor

  • Ken Kousen is the author of the books Kotlin Cookbook (O'Reilly),  Modern Java Recipes (O'Reilly), Gradle Recipes for Android (O’Reilly) and Making Java Groovy (Manning), as well as O’Reilly video courses in Android, Groovy, Gradle, Advanced Java, and Spring. Ken is a Java Champion. He is a regular speaker on the No Fluff, Just Stuff conference tour and a JavaOne Rock Star, and has spoken at conferences all over the world. Through his company, Kousen I.T., Inc., he has taught software development training courses to thousands of students.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Review of Kotlin Features (60 minutes)

  • Immutable types
  • Nullability
  • Defining top-level functions
  • Classes, interfaces, and object singletons
  • Companion objects
  • Conditional expressions
  • Collections and arrays
  • Exercises
  • Q&A
  • Break (10 minutes)

Starting a Spring Boot Application (30 minutes)

  • Adding the Kotlin Gradle plugin
  • Adding the "all-open" plugins
  • Selecting compiler options for nullability
  • Specifying dependencies for the JDK and reflection
  • Preparing for tests
  • Exercise

Spring Controllers in Kotlin (45 minutes)

  • Defining a web controller
  • Working with view templates
  • Defining a restful controller
  • Testing controllers with JUnit 5
  • Q&A
  • Break (10 minutes)

Persistence with JPA (45 minutes)

  • Adding the "kotlin-noarg" dependency
  • Applying the "kotlin-jpa" plugin
  • JPA annotations and data classes
  • Defining a Spring Data JPA repository interface
  • Q&A
  • Break (10 minutes)

Implementing Back-End Services (30 minutes)

  • Using Spring's @Service annotation
  • Extension functions
  • Exposing an HTTP API
  • Mocking objects for testing
  • Exercise
  • Q&A

Additional Features (30 minutes)

  • Externalizing configuration properties
  • Using application.properties
  • Integration and functional testing
  • Final Q&A