A collection of standalone Spring Boot examples written in Kotlin, demonstrating common backend development patterns, reactive programming, data access, messaging, security, external integrations, containerization, and Kubernetes deployment.
This repository is a playground for exploring Spring Boot development with Kotlin.
It is not a single application or a multi-module project. Each directory contains an independent Spring Boot project focused on a specific technology, configuration, or implementation pattern.
The examples cover topics such as:
- Kotlin Coroutines
- Spring WebFlux and reactive programming
- R2DBC and PostgreSQL
- Redis
- Apache Kafka and Spring Cloud Stream
- Elasticsearch
- Spring Cloud Gateway
- WebClient
- Reactive Security and JWT
- TLS and custom truststores
- SFTP integration
- Docker and multi-stage builds
- Kubernetes resources
- Logging and MDC
- Request and response processing
The projects are intended for learning, experimentation, troubleshooting, and use as references when implementing similar features in other Spring Boot applications.
SpringBoot-Kotlin-Playground
├── SpringBoot-Cloud-*
├── SpringBoot-Coroutines-*
├── SpringBoot-Docker-*
├── SpringBoot-Elasticsearch-*
├── SpringBoot-K8s-*
├── SpringBoot-R2DBC-*
├── SpringBoot-Reactive-*
├── SpringBoot-SFTP-*
├── SpringBoot-WebClient-*
├── SpringBoot-WebFilter-*
└── ...
Each project generally contains its own:
project-name
├── src
├── build.gradle.kts
├── settings.gradle.kts
├── gradlew
├── gradlew.bat
├── README.md
└── docker-compose.yaml
Some projects may also include Dockerfiles, Kubernetes manifests, certificates, database scripts, or other supporting resources.
| Project | Description |
|---|---|
| SpringBoot-Cloud-Gateway | Basic Spring Cloud Gateway configuration and request routing. |
| SpringBoot-Cloud-Gateway-AddHeaders | Adding or modifying HTTP headers through Spring Cloud Gateway. |
| Project | Description |
|---|---|
| SpringBoot-Cloud-Kafka-Delay | Implementing delayed message processing with Kafka. |
| SpringBoot-Cloud-Kafka-Header | Producing and consuming Kafka messages with custom headers. |
| SpringBoot-Cloud-Kafka-Multiple-Broker | Configuring an application to communicate with multiple Kafka brokers. |
| SpringBoot-Cloud-Kafka-Stream | Producing and consuming messages with Spring Cloud Stream and Kafka. |
| Project | Description |
|---|---|
| SpringBoot-Coroutines-Functional-Endpoint | Building functional WebFlux endpoints with Kotlin Coroutines. |
| SpringBoot-Coroutines-Redis-Data | Accessing Redis using Kotlin Coroutines and reactive Redis support. |
| Project | Description |
|---|---|
| SpringBoot-Dockerfile | Containerizing a Spring Boot application with a Dockerfile. |
| SpringBoot-Docker-MultiStage | Building a smaller application image with a multi-stage Docker build. |
| Project | Description |
|---|---|
| SpringBoot-Elasticsearch-CoroutineRepository | Accessing Elasticsearch through coroutine-based repositories. |
| SpringBoot-Elasticsearch-ReactiveRepository | Working with Spring Data reactive Elasticsearch repositories. |
| SpringBoot-Elasticsearch-ReactiveTemplate | Querying Elasticsearch through ReactiveElasticsearchTemplate. |
| Project | Description |
|---|---|
| SpringBoot-Jasper-HelloWorld | A basic JasperReports integration example. |
| Project | Description |
|---|---|
| SpringBoot-K8s-Deployment | Deploying a Spring Boot application with a Kubernetes Deployment. |
| SpringBoot-K8s-Env-Variable | Supplying application configuration through environment variables. |
| SpringBoot-K8s-Configmap-Env-Variable | Exposing ConfigMap values as container environment variables. |
| SpringBoot-K8s-Configmap-Mount-File | Mounting a Kubernetes ConfigMap as files inside a container. |
| SpringBoot-K8s-Secret-Variable | Exposing Kubernetes Secret values as environment variables. |
| SpringBoot-K8s-Secret-Mount-File | Mounting Kubernetes Secrets as files inside a container. |
| SpringBoot-K8s-Ingress | Exposing a Spring Boot application through Kubernetes Ingress. |
| SpringBoot-K8s-Volume-PVC | Mounting persistent storage using a PersistentVolumeClaim. |
| Project | Description |
|---|---|
| SpringBoot-Property-Binding | Binding application properties to Kotlin configuration classes. |
| SpringBoot-Logging-Level | Configuring application and package-specific logging levels. |
| SpringBoot-MDC-Logging | Adding contextual information to logs with MDC. |
| SpringBoot-MDC-Logstash | Producing structured logs for Logstash with MDC values. |
| SpringBoot-Modify-Request | Reading or modifying incoming HTTP request data. |
| Project | Description |
|---|---|
| SpringBoot-R2DBC-CoroutineRepository | Accessing a relational database through coroutine-based R2DBC repositories. |
| SpringBoot-R2DBC-R2dbcTemplate | Performing reactive database operations with R2dbcEntityTemplate. |
| Project | Description |
|---|---|
| SpringBoot-Reactive-ExceptionHandler-V1 | Handling exceptions in a Spring WebFlux application. |
| SpringBoot-Reactive-ExceptionHandler-V2 | An alternative global exception-handling implementation for WebFlux. |
| SpringBoot-Reactive-Logging-Request-Response | Logging reactive HTTP request and response information. |
| SpringBoot-ReactiveSecurity-JWT | Securing reactive endpoints with Spring Security and JWT. |
| SpringBoot-Reactive-SSL | Configuring HTTPS for a reactive Spring Boot application. |
| SpringBoot-Reactive-SSL-TrustStore-Client | Configuring a custom client truststore for reactive HTTP requests. |
| SpringBoot-Reactive-SSL-TrustStore-Global | Applying custom truststore configuration globally. |
| Project | Description |
|---|---|
| SpringBoot-SFTP-CachedSession | Reusing and caching SFTP sessions. |
| SpringBoot-SFTP-SharedSession | Sharing an SFTP session across integration operations. |
| SpringBoot-SFTP-InboundChannel | Receiving or downloading files through an SFTP inbound channel adapter. |
| SpringBoot-SFTP-InboundChannel-DSL | Configuring an SFTP inbound flow with the Spring Integration DSL. |
| Project | Description |
|---|---|
| SpringBoot-WebClient | Calling external HTTP APIs with Spring WebClient. |
| SpringBoot-WebClient-Customize | Customizing WebClient and its underlying HTTP client. |
| SpringBoot-WebClient-Filter | Intercepting WebClient requests and responses with exchange filters. |
| SpringBoot-WebClient-ConnectionPool | Configuring Reactor Netty connection pooling for WebClient. |
| Project | Description |
|---|---|
| SpringBoot-WebFilter | Intercepting reactive HTTP requests with Spring WebFilter. |
| SpringBoot-WebFilter-Order | Controlling the execution order of multiple WebFilters. |
| Project | Description |
|---|---|
| SpringBoot-ZipFile-Password | Creating or extracting password-protected ZIP files. |
Clone the repository:
git clone https://github.com/tirmizee/SpringBoot-Kotlin-Playground.git
cd SpringBoot-Kotlin-PlaygroundSelect the example you want to explore:
cd SpringBoot-WebClientRun the application with the included Gradle Wrapper:
./gradlew bootRunOn Windows:
gradlew.bat bootRunTo build the project without starting it:
./gradlew clean buildSome examples require supporting services such as PostgreSQL, Redis, Kafka, Elasticsearch, SFTP, or a mock HTTP server.
When a project includes a docker-compose.yaml or docker-compose.yml file, start its dependencies with:
docker compose up -dThen run the Spring Boot application:
./gradlew bootRunStop the supporting services with:
docker compose downAlways review the selected project's README.md, application.yaml, and Docker Compose configuration before running it.
The exact requirements may vary between projects because the examples were created independently and may use different Spring Boot, Kotlin, Java, and dependency versions.
Commonly required tools include:
- JDK
- Docker and Docker Compose
- Git
- IntelliJ IDEA or another Kotlin-compatible IDE
- A local Kubernetes environment for Kubernetes examples
Check the following files inside each project for the required versions and dependencies:
build.gradle.kts
settings.gradle.kts
application.yaml
docker-compose.yaml
README.md
- Each directory is an independent application.
- Run Gradle commands from inside the selected project directory.
- Configuration values and credentials are intended for local demonstrations only.
- Some projects demonstrate older Spring APIs or dependency versions.
- Review and update dependencies before using an example in a production application.
- Production systems should use secure secret management instead of storing credentials directly in configuration files.
- The examples focus on individual concepts and may intentionally omit production concerns unrelated to the demonstrated topic.
This repository can be used as:
- A Kotlin and Spring Boot learning playground
- A reference for implementing specific Spring features
- A collection of small proof-of-concept applications
- A starting point for troubleshooting integrations
- A source of examples for reactive and coroutine-based development
Created by tirmizee.