One Framework a Day keeps the Boredom Away: Kotlin/Spring5/ReactiveMongoDB

1fdba kotlin 1

Welcome to this new edition of One Framework a Day keeps the Boredom Away. In this series I will show you how to deploy a particular framework on Clever Cloud every day until I want to go back to boredom. Today it's about a bunch of interesting technologies: Kotlin, Spring 5 and MongoDB.

If you want to tag along, make sure you have git, a Clever Cloud account and that you have installed our CLI Clever-Tools.

What is Kotlin, Spring 5 and Reactive MongoDB?

This time we get to talk about all these things in one post because of a code sample I found. Someone on twitter asked us if Kotlin code could be deployed on Clever Cloud. The answer is yes. You can deploy anything that can be packaged as a Jar or War. So that means Kotlin, but also Ceylon, Clojure, Groovy, Scala and many more. So what is Kotlin?

Kotlin is a statically-typed programming language that runs on the Java virtual machine and also can be compiled to JavaScript source code or use the LLVM compiler infrastructure.

It's also worth noting that it can target native environment beyond the JVM. So it can be used to write iOS app for instance. This post on multiplatform native developement with Kotlin will give you a better idea of the many things you can do.

Anway I looked for a Kotlin sample online and I found the traditional Pet Clinic sample written in Kotlin with Spring 5 and Reactive MongoDB. Which is nice because Spring 5 is all about being reactive. And Kotlin is a great fit for that because of its Lambdas support. But we are not going to look at the code, we are going to look at how to deploy this Kotlin/MongoDB project on Clever Cloud.

Setup

Here are the steps you need to go through to deploy this application:

  • Clone the project: git clone https://github.com/ssouris/petclinic-spring5-reactive
  • Get in the project: cd petclinic-spring5-reactive
  • Create our PostgreMongoDB add-on: clever addon create mongodb-addon --plan peanut petClinicMongo
  • Create our application: clever create --type gradle petClinic
  • Link our MongoDb add-on: clever service link-addon petClinicMongo

Setup the necessary environment variables for configuration:

clever env set GRADLE_DEPLOY_GOAL bootRun
clever env set SPRING_DATA_MONGODB_URI `clever env | awk  -F = '/MONGODB_ADDON_URI/ { print $2}'`

Here we start by specifying which Gradle goal to run. This goal compiles and runs the application. Then we configured the MongoDB connection.

Deploy

To deploy your application, run clever deploy then clever open. You should see the logs of your application being ran successfuly then have the website open in your default web browser. And as you can see your Kotlin project is up and running and talking to a MongoDB database the reactive way.

Blog

À lire également

UP Program: Clever Cloud announces its fifth startup selection

With this new batch, Clever Cloud welcomes four startups to the UP Program: Sentibee, Pictaderm, Legaia and Cockpit Agriculture.
Company

Sōzu 2.0 — turning a reverse proxy into a programmable edge

Sōzu is the reverse proxy that sits in front of every application running on Clever Cloud. After eighteen months of work — first the HTTP/2 multiplexer, built on our existing kawa pivot, then almost every other layer of the proxy, and finally a long run in production on the cleverapps.io load balancers — Sōzu 2.0 is out.
Engineering

K3s vs K8s: What Are the Differences and Which One Should You Choose in 2026?

Kubernetes has become the standard for container orchestration. But depending on your infrastructure constraints (limited resources, edge computing, IoT, or large-scale enterprise clusters), the distribution you choose can radically change the operational experience. K3s and K8s (upstream Kubernetes) address different needs, even though both share the same CNCF-certified foundation.
Engineering Features