LoginSignup
1
5

More than 5 years have passed since last update.

【Kotlin】Spring DevTools におけるホットデプロイの設定

Last updated at Posted at 2018-10-22

 概要

  • Spring Boot を用いた開発をするときに毎回と言っていいほどホットデプロイの設定でつまづくので備忘録として設定の手順を残しておこうと思います。Spring Bootのバージョンは 2.0.6, ビルドシステムは gradle を使用します。

1. SPRING INITIALIZR で Devtools の Dependency を追加

スクリーンショット 2018-10-23 9.49.55.png

2. 自動ビルドの設定を有効にする

ここからはIntelliJでの作業になります。

  • shift * 2 でなんでも検索を起動(私はなんでも検索を使わないと設定箇所を特定できなかったのでこの方法をとっています。)
  • 「settings」 とタイプし、下の方の「Default Settings」 を選択する
    スクリーンショット 2018-10-22 23.43.58.png

  • 「Build, Execution, Deployment」 -> 「Compiler」 の 「Build project automatically」にチェックを入れる
    スクリーンショット 2018-10-22 23.49.13.png

  • 再びなんでも検索を起動し、「registry」 とタイプし、一番下の「Registry」 を選択
    スクリーンショット 2018-10-22 23.56.35.png

  • 「compiler.automake.allow.when.app.running」 にチェックを入れる。
    スクリーンショット 2018-10-22 23.57.55.png

3. build.gradle の設定

  • build.gradle に以下を追加
build.gradle
apply plugin: 'idea'
idea {
    module {
        inheritOutputDirs = false
        outputDir = file("$buildDir/classes/kotlin/main")
    }
}

以上の設定をするとファイルが更新された時点で自動的に変更が反映されるようになります。

参考文献

Spring Boot (Kotlin) はじめの一歩
Spring Boot — Hot Swapping a Gradle project in IntelliJ with Kotlin support

1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5