How to start Kotlin development with SpringBoot + Maven + SpringToolSuite

In the tutorial, Kotlination will help you the first step for starting with Kotlin language by building a example Kotlin HelloWorld using SpringBoot, Maven and SpringToolSuite.

>>> Refer to: JavaSampleApproach

I. Technologies

– Java 1.8
– Maven 3.3.9
– Spring Tool Suite – Version 3.8.1.RELEASE
– Spring Boot: 1.5.6.RELEASE
– Kotlin language

II. Practice

Step to do:
– Create SpringBoot project with Kotlin language
– Install Kotlin Plugin for Eclipse
– Run and check results

1. Create SpringBoot project with Kotlin language

Open SpringToolSuite, choose File -> New -> Other -> Spring Starter Project:

springboot kotlin helloworld - spring starter project

Press Next, then input project info as below image:

springboot kotlin helloworld - input project infor

Press Next -> Finish, we got:

springboot kotlin helloworld - project structure

Take a look at pom.xml file:

2. Install Kotlin Plugin for Eclipse

What is Kotlin Plugin for Eclipse?
-> The Kotlin Plugin for Eclipse helps you write, run, debug and test programs in Kotlin language.

How to install it?

On main Menu, choose Help -> Install New Software….
Add kotlin plugin for eclipse with link: https://dl.bintray.com/jetbrains/kotlin/eclipse-plugin/last/

springboot kotlin helloworld - add kotlin plugin for eclipse

We got:

springboot kotlin helloworld - add kotlin plugin for eclipse - we got

Check Kotlin as above image, then press Next.
Now follow the guides to install Kotlin plugin. After all is Done, we will get a Software Update message dialog.

springboot kotlin helloworld - restart notified for effect updates

Press Yes to restart SpringToolSuite for the changes to take effect.
-> Result:

springboot kotlin helloworld - project structure - updated

3. Run and check results

Open class SpringKotlinHelloWorldApplication, then add some println line of codes as below:

Build the project with commandline mvn clean install -Dmaven.test.skip=true:

springboot kotlin helloworld - build kotlin project

Run the Kotlin SpringBoot project with commandline mvn spring-boot:run.
-> Results:

springboot kotlin helloworld - run results

III. Sourcecode

SpringKotlinHelloWorld

Add Comment