Spring Boot
Spring BootでCommandLineRunnerを使うと、起動時に初期化処理を実行することができる @Bean fun run(): CommandLineRunner { return CommandLineRunner { // 何らかの処理 } } @Component class Hoge : CommandLineRunner { override fun run(vararg args: …
IntelliJ IDEA + Spring Boot DevToolsで自動リロードさせることができる。 Preferences > Build, Execution, Deployment > Compiler を開き、 Build project automatically を有効にする。 ⌘ + Shift + a で Registry... を選択する。 compiler.automake.al…
Spring Bootでアプリケーション設定ファイル(application.propertiesやyml)の設定値を取得するには org.springframework.core.env.StandardEnvironment を使用する。 例 @RestController class HogeRestController(private val environment: StandardEnvir…
Kotlin Spring Boot 2.0.4 Thymeleaf Spring Bootで、Imgタグに表示する画像をByte配列を返すには、ResponseEntityを使用する。 Controllerの実装 @GetMapping("image") fun image(): ResponseEntity<ByteArray> { val bytes = .. // 画像のByte配列を取得 return Respo</bytearray>…