springのdevtoolsの自動再起動機能を試した。
気づいたのはdevtoolsのrestartの設定はデフォルト:trueだったこと。
リロード速度
- クラスの変更は再起動に3秒ぐらい(クラスの数に影響しそう)
- Thymeleafの変更は再起動なしですぐ反映される
dependenciesにdevtools設定
build.gradle
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
developmentOnly 'org.springframework.boot:spring-boot-devtools' // ここ追記した
}
application.ymlにrestart設定
restart設定のデフォルトは true
あえてfalseにしないなら設定不要。
application.yml
spring:
devtools:
restart:
enabled: true
リロード確認
確認対象 | devtoolsなし | devtools利用 | restartあえてfalse |
---|---|---|---|
Controllerメソッド処理変更 | ![]() |
![]() |
![]() |
Controller@RequestMapping のついたメソッドを追加 |
![]() |
![]() |
![]() |
Controllerクラス追加 | ![]() |
![]() |
![]() |
Thymeleaf内容編集 | ![]() |
![]() |
![]() |
Thymeleafファイル追加 | ![]() |
![]() |
![]() |