Kotlin 1.2.0 + Spring create Web Application (1 of 4)

Let’s create an application with Kotlin and Spring. Spring is a highly sophisticated framework in Java, which can do almost everything.


Kotlin and Spring. And kotlinx.html for view. (Thymeleaf can be used, too.) Project structure is managed by Gradle. Intellij IDEA Community Edition for the editor.

  • Gradle 4.4
  • Kotlin 1.2.0
  • kotlinx.html 0.6.6
  • Spring Boot 1.5.8
  • PostgreSQL 9.5.6
  • Intellij IDEA 2017.2.6 (Community Edition)
    • Kotlin Plugin 1.2.0-release-IJ2017.2-1
  • OpenJDK 1.8

The version of Kotlin plugin can be checked in Intellij IDEA menu, Tools -> Kotlin -> Configure kotlin Plugin Updates.

Create the application base

Build the project with the wizard in Intellij IDEA. At the left pane in New Project dialog, select “Gradle” and check “Kotlin (Java)” and push “Next” button. “Multiplatform” shown in the dialog is trial feature from Kotlin 1.2.0, which is for cross compilation, but this time we don’t use it.

GroupId, ArtifactId are to be “com.example”, “myapp”

Now the file “build.gradle” is as follows.

If the version of Gradle Wrapper is less than 4.4, please upgrade it by executing ./gradlew wrapper --gradle-version=4.4. The version of Gradle Wrapper can be checked by executing ./gradlew -v.

build.gradledependenciescompile("org.springframework.boot:spring-boot-starter-web:1.5.8.RELEASE") を追加します。

Create Application class and create main method of Spring Boot.

Then, the serve can work.

Continues to Kotlin 1.2.0 + Spring: create Web Application (2 of 4)