Build Web Application with Kotlin 1.1.61 and Spring で Web Application (1 of 4)


Let’s create web application with Kotlin and Spring. Spring is really sophisticated Java framework, and can do almost of all everything.

This time, I use kotlinx.html for view template. (Thymeleaf also can be used.) In kotlinx.html, we can write everything in Kotlin grammar. For project structure management, I use Gradle. Intellij IDEA Community Edition for editor.

Environment

  • Gradle 4.3.1 (In the middle of article, I upgrade Gradle version to 4.4 RC 1)
  • Kotlin 1.1.61
  • kotlinx.html 0.6.6
  • Spring Boot 1.5.8
  • PostgreSQL 9.5.6
  • Intellij IDEA 2017.2.6 (Community Edition)
  • OpenJDK 1.8

Build base of the application

Generate base with Intellij IDEA wizard. ファイルメニューから 新しいプロジェクトを作成します。 “New Project” dialog will be shown, then choose Gradle in left pain, check “Kotlin (Java)”, click “Next”.

Set GroupId, ArtifactId to com.example, myapp respectively.

Then, build.gradle is as follows.

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

Create Spring Boot main method.

Now, server will work.。

Continue to Kotlin 1.1.61 + Spring で Web Application を作る (2 of 4).