LoginSignup
45
32

More than 5 years have passed since last update.

IntelliJ の Spring Boot を使ったプロジェクトでコード変更時に自動で再コンパイルする設定

Last updated at Posted at 2017-06-08

Spring Boot を使ったアプリケーションを IntelliJ で書いていたけど、コード変更時の自動再コンパイルの設定に少し苦労したのでメモ。

spring-boot-devtools

オフィシャルのドキュメントには spring-boot-devtoolsdependencies に追加するといい、的なことが書かれていた。

build.gradle は次のような感じになる。

dependencies {
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('org.springframework.boot:spring-boot-devtools')

    testCompile('org.springframework.boot:spring-boot-starter-test')
}

でも、これだけでは自動での再コンパイルは行われないようであった。

Preference の設定と Registry の設定

Stack Overflow の記事に、もう少し踏み込んだ内容があった。次のふたつの設定をするといいらしい。

  1. "Preferences..." で "Build project automatically" にチェックを入れる
  2. "Command + Shift + a" で表示されるダイアログに "Registry" とタイプし、"compiler.automake.allow.when.app.running" にチェックを入れる

これで、たしかに自動での再コンパイルが機能するようになった。

各々のスクリーンショットを貼り付けておく。

Build project automatically

preference-compiler.png

compiler.automake.allow.when.app.running

auto-reload.png

45
32
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
45
32