Spring Boot を使ったアプリケーションを IntelliJ で書いていたけど、コード変更時の自動再コンパイルの設定に少し苦労したのでメモ。
spring-boot-devtools
オフィシャルのドキュメントには spring-boot-devtools
を dependencies
に追加するといい、的なことが書かれていた。
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 の記事に、もう少し踏み込んだ内容があった。次のふたつの設定をするといいらしい。
- "Preferences..." で "Build project automatically" にチェックを入れる
- "Command + Shift + a" で表示されるダイアログに "Registry" とタイプし、"compiler.automake.allow.when.app.running" にチェックを入れる
これで、たしかに自動での再コンパイルが機能するようになった。
各々のスクリーンショットを貼り付けておく。
Build project automatically

compiler.automake.allow.when.app.running
