--- title: KotlinでSpring Boot入門 springboot tags: ["Kotlin", "Spring", "Spring Boot"] categories: ["Programming", "Java", "Kotlin"] date: 2014-06-28T21:35:41Z updated: 2014-06-28T21:35:41Z --- 「[Kotlinことはじめ](/#/entries/273)」と「[Spring BootとSpring LoadedでサクサクHot Reloading Java Webアプリ開発 #springboot](/#/entries/265)」の組み合わせネタです。普通に出来ました。 pom.xml 4.0.0 com.example hajiboot-kotlin 1.0.0-SNAPSHOT jar hajiboot-kotlin org.springframework.boot spring-boot-starter-parent 1.1.3.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.jetbrains.kotlin kotlin-stdlib ${kotlin.version} org.springframework.boot spring-boot-maven-plugin org.springframework springloaded 1.2.0.RELEASE kotlin-maven-plugin org.jetbrains.kotlin ${kotlin.version} compile process-sources compile test-compile process-test-sources test-compile 0.7.270 1.8 com.example.ExamplePackage ほぼ前述の2記事の組み合わせです。注意ポイントは``に``でエントリポイントのFQCNを明示的に設定すること。Kotlinでコンパイルすると`main`メソッドのあるクラスが2つできるっぽいので。`com.example`パッケージに`main`関数がある場合は、`com.example.ExamplePackage`を設定する。 `src/main/java/com/example/App.kt`を作成。 package com.example import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.boot.SpringApplication EnableAutoConfiguration RestController class App { RequestMapping fun hello(): String { return "Hello World!" } } fun main(args: Array) { SpringApplication.run(array(javaClass()), args); } あとは`mvn spring-boot:run`を実行。http://localhost:8080 にアクセスすれば ![image](https://qiita-image-store.s3.amazonaws.com/0/1852/a4bde45b-85da-be3f-dc68-18e1b99604eb.png) 普通にいけますね。spring-loadedのHot Reloadも効きます。 KotlinにWebフレームワークの決定版ないみたいだし、これでいいんじゃないの?