LoginSignup
15
10

More than 5 years have passed since last update.

IntelliJ IDEA にてSpring Boot Devtools の Restart が機能しない

Last updated at Posted at 2017-07-19

Spring Boot Devtools を IntelliJ IDEA で動かす

IntelliJ IDEA にて Spring Boot Devtools の設定をした際、一向に変更が反映されず、はまってしまったので備忘録。
結論としては、こちらの記事のとおりでした。
素晴らしい記事です。

シクりポイント

  1. 魔法の力を信じてしまった

I am guessing you are coding and expect DevTools to auto-magically figure out you have changed something in your project? Devtools does that by watching your classpath folder(s). When a .class file (or a resource) has changed, devtools take the appopriate action.

2.レジストリの設定を知らなかった

これは何か? 公式でも出てこない気がする。。

compiler.automake.allow.when.app.running

2017/08 追記
3. main メソッドから起動しなかった

タスクランナーとして Gradle を使用していますが、アプリケーションの起動タスクとして、bootRun があります。
bootRun から起動すると、Gradle のビルド先である $projectRoot/build がリソースの変更対象として監視されるようになります。

14:42:38.506 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
14:42:38.509 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
14:42:38.509 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/Users/userName/Documents/workspace/projectName/build/classes/main/, file:/Users/userName/Documents/workspace/projectName/build/resources/main/]

しかしながら、IntelliJ IDEA にてコンパイルすると成果物は、$projectRoot/out 配下に配置されます。
$projectRoot/build 配下にリソースを配置する役目は Gradle となりますが、Gradle が動作するきっかけがありません。
このため、main メソッドからアプリケーションを起動させて、$projectRoot/out フォルダ配下を変更の監視対象にします。

14:32:12.395 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
14:32:12.398 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
14:32:12.398 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/Users/userName/Documents/workspace/projectName/out/production/classes/, file:/Users/userName/Documents/workspace/projectName/out/production/resources/]

15
10
2

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
15
10