Web Development · WDC-98

RESTful API with Spring Boot and Kotlin

RESTful API with Spring Boot and Kotlin is a hands-on course in building REST APIs with Spring Boot 4 and Kotlin 2, covering validation, ProblemDetail errors, Spring Data JPA, Spring Security with JWT, RestClient and testing with MockK and Testcontainers. It suits Java developers who have used Spring Boot and IT staff who run API services, and you leave able to ship a production-ready Kotlin API.

Updated
From 8,550 THB / person 9,500 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration18 hours · 3 days
  • FormatOnsite / live online
  • Next roundOn request
  • CertificateIncluded

Course overview

Kotlin is officially supported by Spring. It is more concise than Java, safer around null values and runs on the JVM alongside every existing Java library, so many backend teams choose Kotlin with Spring Boot for new services. Yet many examples online still use Spring Boot 2 and RestTemplate, which is now deprecated, so applying them to Spring Boot 4 and Spring Framework 7 runs into changed APIs and approaches that are no longer recommended.

This course takes developers with a Java and Spring Boot background through the parts of Kotlin 2 that matter for API work: null safety, data classes, sealed classes, collections, lambdas, scope functions and an introduction to coroutines. Learners then build RESTful APIs with Spring Boot 4, from resource design to controllers, DTOs and validation, error handling with ProblemDetail and API versioning. They store data in PostgreSQL with Spring Data JPA and Flyway, secure the API with Spring Security and JWT, call external APIs with RestClient and HTTP service clients, write tests with JUnit, MockK and Testcontainers, and produce OpenAPI documentation and a Docker image. The course closes with an end-to-end capstone API. (3 days, 6 hours per day, 18 hours in total, Intermediate level.)

What you’ll gain

  • Write Kotlin 2 fluently, including null safety, data classes, sealed classes, collections and scope functions
  • Create Spring Boot 4 projects with Kotlin and the Gradle Kotlin DSL
  • Design and build RESTful APIs with validation, ProblemDetail and API versioning
  • Store data in PostgreSQL with Spring Data JPA and manage the schema with Flyway
  • Secure APIs with Spring Security and JWT, with role-based permissions
  • Call external APIs with RestClient and HTTP service clients instead of RestTemplate
  • Write unit and integration tests with JUnit, MockK and Testcontainers

Who this course is for

  • Java developers who want to start using Kotlin with Spring Boot
  • Backend developers who want to bring their REST APIs up to Spring Boot 4
  • IT staff and system administrators who build or look after their organisation's API services
  • Android teams who already use Kotlin and want to build the backend in the same language

Prerequisites

  • Able to write Java, with an understanding of OOP, interfaces and collections
  • Have built an application with Spring Boot before, even a sample project
  • Have used IntelliJ IDEA and understand HTTP methods, status codes and JSON
  • Basic SQL; no prior Kotlin is needed
  • A laptop that can run JDK 25, IntelliJ IDEA and Docker Desktop, with permission to install software

Curriculum

Course Details

This course is the 2026 edition that replaces the previous RESTful API with Spring Boot and Kotlin course, which was taught on an earlier Spring Boot and used RestTemplate. It has been rewritten for Spring Boot 4.1, Spring Framework 7 and Kotlin 2. It runs for 3 days, 6 hours per day (18 hours in total, 09:00-16:00), as lectures with labs built on a single API project. Intermediate level. New content covers Spring Data JPA with PostgreSQL, Flyway, ProblemDetail, API versioning, Spring Security with JWT, RestClient, Testcontainers, OpenAPI and Docker. It follows on from Basic Java Programming and focuses on REST APIs in Kotlin, unlike Microservices with Spring Boot and Spring Cloud, which focuses on multi-service architecture.

Day 1 Kotlin 2 for Java Developers

Section 1: Lab: Getting Started with Kotlin 2 and Its Tools

  • How Kotlin runs on the JVM and where it improves on Java
  • The K2 compiler and setting up a project in IntelliJ IDEA
  • The Gradle Kotlin DSL and the structure of build.gradle.kts
  • Call existing Java classes from Kotlin and the other way round
  • Lab: convert short Java snippets to Kotlin

Section 2: Language Basics and Null Safety

  • val and var, type inference and string templates
  • if and when as expressions, ranges and loops
  • Nullable types, safe calls (?.), the Elvis operator (?:) and smart casts
  • Why to avoid the non-null assertion (!!)
  • Lab: functions that check and convert data that may be null

Section 3: Functions, Classes and Data Classes

  • Default and named arguments, and extension functions
  • Classes, primary constructors and init
  • Data classes for DTOs, with copy() and equals()
  • Sealed classes and sealed interfaces for multiple result types
  • object, companion objects and visibility modifiers

Section 4: Lab: Collections, Lambdas and Scope Functions

  • Read-only and mutable List, Set and Map
  • map, filter, flatMap, groupBy and associateBy
  • Sequences for lazy processing of large data sets
  • Scope functions: let, apply, also, run and with
  • Lab: summarise order data with the collections API

Section 5: Error Handling and an Introduction to Coroutines

  • Exceptions in Kotlin, runCatching and Result
  • Model success and failure with sealed classes
  • suspend functions and coroutine scopes
  • Run several tasks concurrently with async and await
  • Lab: fetch data from several sources at once and combine the results
Day 2 Building RESTful APIs with Spring Boot 4

Section 6: Lab: Starting a Spring Boot 4 Project in Kotlin

  • Create a project with Spring Initializr using Kotlin and Gradle
  • What changed in Spring Boot 4 and Spring Framework 7, such as Jackson 3 and JSpecify
  • The kotlin-spring plugin and constructor injection
  • Configuration with application.yml, profiles and @ConfigurationProperties
  • Lab: a first endpoint with per-environment settings

Section 7: RESTful API Design Principles

  • Resources, URIs and choosing the right HTTP method
  • Which status codes to use in each situation
  • The Richardson Maturity Model and levels of REST
  • Pagination, filtering and sorting
  • API versioning with the new support in Spring Framework 7

Section 8: Lab: Controllers, DTOs and Validation

  • @RestController and mappings for every HTTP method
  • Request and response DTOs as data classes
  • Bean Validation in Kotlin with @field: and @Valid
  • ResponseEntity and the headers to return
  • Lab: a CRUD API for product management with in-memory storage

Section 9: Error Handling with ProblemDetail

  • Standard error responses following RFC 9457 with ProblemDetail
  • @RestControllerAdvice and a central exception handler
  • Domain exceptions modelled with sealed classes
  • Return validation errors in a form the frontend can use easily
  • Lab: make the whole API return errors in one consistent format

Section 10: Lab: Spring Data JPA with PostgreSQL

  • Run PostgreSQL with Docker Compose
  • Entities in Kotlin with the kotlin-jpa plugin, and pitfalls to avoid
  • Repositories, query methods and Pageable
  • Manage the schema with Flyway migrations
  • Lab: move the product API to store data in PostgreSQL
Day 3 Security, Integration, Testing and Deployment

Section 11: Lab: Securing the API with Spring Security

  • SecurityFilterChain with the Kotlin DSL
  • JWT authentication as an OAuth2 resource server
  • Role-based permissions at URL and method level
  • Configure CORS and keep secrets safe
  • Lab: log in, issue tokens and protect admin endpoints

Section 12: Calling External APIs with RestClient

  • RestClient in place of the deprecated RestTemplate
  • HTTP service clients with interfaces and @HttpExchange
  • Handle errors, timeouts and retries sensibly
  • Map external API data to data classes
  • Lab: connect an external API to enrich the product data

Section 13: Lab: Testing with JUnit, MockK and Testcontainers

  • Unit tests for services with JUnit and MockK
  • Test the web layer with @WebMvcTest and MockMvc
  • Integration tests with @SpringBootTest
  • Test against a real PostgreSQL with Testcontainers
  • Lab: write tests covering controllers, services and repositories

Section 14: API Documentation and Production Readiness

  • Generate OpenAPI documentation and Swagger UI with springdoc-openapi
  • Health checks and metrics with Spring Boot Actuator
  • Structured logging and request tracing
  • Build a Docker image with bootBuildImage or a Dockerfile

Section 15: Workshop: End-to-End Capstone API

  • Pick a brief, such as a meeting room booking or ordering system
  • Design the resources, DTOs and error responses
  • Build it with JPA, validation and security
  • Write tests and build a Docker image
  • Present the work, review the code together and plan next steps

Schedule & training options

For individuals — public rounds

No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770

For organisations — in-house / private

  • Tailor the content to your team’s tools and projects
  • Your dates, at your office or live online
  • Quotation with tax ID for procurement
Corporate training quote

Instructors

Frequently asked questions

How does Kotlin handle null values?

Kotlin separates nullable types from non-nullable ones: String cannot be null, but String? can. The compiler will not let you use a possibly null value directly, so you use a safe call (?.), which returns null instead of failing, the Elvis operator (?:) for a fallback, or an if check after which a smart cast treats the value as non-null. The non-null assertion (!!) throws a NullPointerException on null, so use it as little as possible. With Spring Framework 7's JSpecify annotations, Kotlin also knows which Spring APIs can return null.

How do I build a REST controller with Spring Boot and Kotlin?

Create a project with Spring Initializr, choosing Kotlin and adding Spring Web. Write a class with @RestController and @RequestMapping for the base path, then add functions with @GetMapping, @PostMapping, @PutMapping and @DeleteMapping. Read input with @PathVariable, @RequestParam or a data class @RequestBody, validate it with @Valid, and delegate to a service received through constructor injection. Return JSON with a suitable status code, and use ProblemDetail for standard error responses.

Why should I move from RestTemplate to RestClient?

In current Spring Framework releases RestTemplate is deprecated, and Spring recommends RestClient instead. RestClient is a synchronous client with a fluent, readable API and convenient status-based error handling, and it shares infrastructure with RestTemplate, so you can migrate gradually. You can also use HTTP service clients, where you declare an interface with @HttpExchange and Spring generates the client, which keeps code short and easy to test.

Who is the RESTful API with Spring Boot and Kotlin course for, and what should I know beforehand?

It suits Java developers who want to start using Kotlin with Spring Boot, backend developers moving to Spring Boot 4, IT staff and administrators who look after API services, and Android teams already using Kotlin. You should be able to write Java, have built an application with Spring Boot and have used IntelliJ IDEA. Kotlin itself is taught from the basics on the first day.

What will I be able to do after the RESTful API with Spring Boot and Kotlin course?

You will be able to write Kotlin with null safety, data classes, sealed classes, collections and scope functions, build RESTful APIs with Spring Boot 4 including validation, ProblemDetail and API versioning, store data in PostgreSQL with Spring Data JPA and Flyway, secure APIs with Spring Security and JWT, call external APIs with RestClient, write tests with JUnit, MockK and Testcontainers, document the API with OpenAPI and build a Docker image. Participants who complete the training receive a Certificate of Completion with its own number, which can be verified online.

What software do I need for the RESTful API with Spring Boot and Kotlin course?

You use JDK 25 and IntelliJ IDEA to write Kotlin and Spring Boot code, Docker Desktop to run PostgreSQL and Testcontainers, and Postman or Bruno to test the API. Other libraries such as Spring Security, Flyway, MockK and springdoc-openapi are added through Gradle in the project. All tools are open source or free, so you just need a laptop that can install them.

Related articles

Articles are published in Thai.