Hello World with Spring Boot + Kotlin

Spring Boot

In this post, we will create a very simple hello world example by using the Spring Boot with Kotlin language. The key idea is to implement a rest controller to return the famous message: Hello World!

The first step to manage the project is to use a build management system such as Gradle or Maven. In this tutorial, we will use Gradle to compile and run the project.

Create an Empty Spring Boot Project

Here is the final representation of the choices

Spring Initializr Page

There is nothing special about now but we can even run the project by the using following command from terminal (for MacOS and Linux environments).

For MacOS and Linux environments
./gradlew bootRun

For Windows the following one must be executed in the project repository:

gradlew bootRun
Starting Spring Boot with Gradle

Gradle will download required components by reading the required libraries from build.gradle in the project. Since we downloaded it from the spring.io page. If you check this file, you will see that it contains Spring Boot and Kotlin related libraries.

Lets Create The Rest Controller

HelloWorldController returns Hello World for http://localhost:8080

This is the first introduction tutorial about the Spring Boot. There are many pre-configured options, and we have not examined the structure of the project yet. I plan to write about more advanced features of Spring Boot such as logging, scheduling, containerization, integration with other popular technologies such as MongoDB.

Software Engineer