LoginSignup
4
4

More than 5 years have passed since last update.

IntelliJ CE + Spring Boot + Gradle + Kotlinで Hot Deploy(Hot Swapping)

Posted at

少しハマったので

参考

前提条件

IntelliJのバージョンが古いと対応していない場合があるので、最新にアップデートしておく
→これにハマりました

手順

ほとんど 参考URL の通りです。

1. IntelliJで対象プロジェクトを開く。

2. COMMAND + SHIFT + A(多分、windowsだと、CTRL + SHIFT + A)キー入力後、「build project automatically」と入力して、[build project automatically]を選択。

3. [preference] -> [build project automatically]にチェックを入れて、OKする
スクリーンショット 2018-06-22 12.37.29.png

4. COMMAND + SHIFT + A(多分、windowsだと、CTRL + SHIFT + A)キー入力後、「Registry」と入力して、[Registry...]を選択。

5. [compiler.automake.allow.when.app.running]にチェックを入れる。
スクリーンショット 2018-06-22 12.42.45.png

6. build.gradle に下記を追加。

build.gradle
apply plugin: 'idea'


dependencies {
    compile('org.springframework.boot:spring-boot-devtools')
}


idea {
    module {
        inheritOutputDirs = false
        outputDir = file("$buildDir/classes/kotlin/main")
    }
}

7. [bootRun]でデバッグ実行。設定がうまく適用されていると、実行後にktファイルを変更して保存すると、spring bootが自動で再実行されるようになります。

うまくいかないときは

  • メインメニュー[File] -> [Invalidate Caches / Restart...] 選択 -> [Invalidate and Restart]を選択(キャッシュを消して、IntelliJ再起動)でうまくいくことがあるらしいです(わたしはやらなくても大丈夫でした)。

スクリーンショット 2018-06-22 11.57.30.png
スクリーンショット 2018-06-22 11.57.36.png

4
4
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
4
4