Back to

Well, if you need some logos, we provide these:

svg ·  png
Red Clever Cloud logo
svg ·  png
svg ·  png
White Clever Cloud logo
svg · png
White Clever Cloud logo
svg · png
Posted at November 8, 2017 — Features

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

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.


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

  • Clone the project: git clone
  • 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.


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.


Laurent Doguin

Head of Developer Relation @clever_cloud. Devoxx Champion. I am also a nerdy metal head living in Paris.

Check out our Blog

We write about programming, security and Clever Cloud products

Join thousands of developers already using Clever Cloud. And try it for free!

Create your account now to start your apps and collaborate within a few minutes. For free with 20€ offered.

By signing up, your agree to our terms of use
Sign in with Github