Spring Boot 1.5.x の Web アプリを 2.0.x へバージョンアップする ( その29 )( build.gradle の dependencies から不要な記述を削除する )
概要
記事一覧はこちらです。
Spring Boot 1.5.x の Web アプリを 2.0.x へバージョンアップする ( その28 )( Docker で SMTPサーバ+Webmailクライアント環境を構築する ) の続きです。
- 今回の手順で確認できるのは以下の内容です。
- Spring Boot 2.0 Release Notes、Spring Boot 2.0 Migration Guide を見直していて、build.gradle の dependencies から削除してよい記述が見つかったので削除します。
参照したサイト・書籍
目次
- build.gradle の dependencies block から thymeleaf-extras-java8time を削除する
- build.gradle の dependencies block から jackson-datatype-jsr310 を削除する
- build.gradle の dependencies block から記述不要のものを削除する
手順
build.gradle の dependencies block から thymeleaf-extras-java8time を削除する
Spring Boot 2.0 Release Notes に The Thymeleaf starter now includes thymeleaf-extras-java8time which provides support for javax.time types.
の記述があります。
今は build.gradle の dependencies block に implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
と implementation("org.thymeleaf.extras:thymeleaf-extras-java8time")
を記述していますが、gradlew dependencies
コマンドを実行してみると確かに org.thymeleaf.extras:thymeleaf-extras-java8time
が2重に出力されていました。
+--- org.springframework.boot:spring-boot-starter-thymeleaf -> 2.0.6.RELEASE | +--- org.springframework.boot:spring-boot-starter:2.0.6.RELEASE (*) | +--- org.thymeleaf:thymeleaf-spring5:3.0.10.RELEASE | | +--- org.thymeleaf:thymeleaf:3.0.10.RELEASE | | | +--- ognl:ognl:3.1.12 | | | | \--- org.javassist:javassist:3.20.0-GA -> 3.22.0-GA | | | +--- org.attoparser:attoparser:2.0.5.RELEASE | | | +--- org.unbescape:unbescape:1.1.6.RELEASE | | | \--- org.slf4j:slf4j-api:1.7.25 | | \--- org.slf4j:slf4j-api:1.7.25 | \--- org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.1.RELEASE | +--- org.thymeleaf:thymeleaf:3.0.0.RELEASE -> 3.0.10.RELEASE (*) | \--- org.slf4j:slf4j-api:1.6.6 -> 1.7.25 +--- org.thymeleaf.extras:thymeleaf-extras-springsecurity5 -> 3.0.3.RELEASE | \--- org.slf4j:slf4j-api:1.7.25 +--- org.thymeleaf.extras:thymeleaf-extras-java8time -> 3.0.1.RELEASE (*)
build.gradle の dependencies block から implementation("org.thymeleaf.extras:thymeleaf-extras-java8time")
を削除します。
build.gradle の dependencies block から jackson-datatype-jsr310 を削除する
Spring Boot 2.0 Migration Guide - Jackson / JSON Support の内容に従い spring-boot-starter-json を使用するよう変更しようと思いましたが、gradlew dependencies
コマンドを実行すると spring-boot-starter-web の依存関係に入っていました。
+--- org.springframework.boot:spring-boot-starter-web -> 2.0.6.RELEASE | .......... | +--- org.springframework.boot:spring-boot-starter-json:2.0.6.RELEASE | | +--- org.springframework.boot:spring-boot-starter:2.0.6.RELEASE (*) | | +--- org.springframework:spring-web:5.0.10.RELEASE | | | +--- org.springframework:spring-beans:5.0.10.RELEASE (*) | | | \--- org.springframework:spring-core:5.0.10.RELEASE (*) | | +--- com.fasterxml.jackson.core:jackson-databind:2.9.7 | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0 | | | \--- com.fasterxml.jackson.core:jackson-core:2.9.7 | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7 | | | +--- com.fasterxml.jackson.core:jackson-core:2.9.7 | | | \--- com.fasterxml.jackson.core:jackson-databind:2.9.7 (*) | | +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7 | | | +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0 | | | +--- com.fasterxml.jackson.core:jackson-core:2.9.7 | | | \--- com.fasterxml.jackson.core:jackson-databind:2.9.7 (*) | | \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.7 | | +--- com.fasterxml.jackson.core:jackson-core:2.9.7 | | \--- com.fasterxml.jackson.core:jackson-databind:2.9.7 (*) | ..........
spring-boot-starter-json の依存関係に com.fasterxml.jackson.datatype:jackson-datatype-jsr310 が入っているので、build.gradle の dependencies block から implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
を削除します。
build.gradle の dependencies block から記述不要のものを削除する
他にも記述しなくてもよいものがありそうだったので、見直して以下のように変更しました。
- spring-boot-starter-thymeleaf に
exclude group: "org.codehaus.groovy", module: "groovy"
を記述していましたが、今は spring-boot-starter-thymeleaf の依存関係に groovy が入っていなかったので削除します。 - spring-session-data-redis の依存関係に spring-session-core が入っていたので、
implementation("org.springframework.session:spring-session-core")
を削除します。 - spring-boot-starter-test の依存関係に mockito-core が入っていたので、
testImplementation("org.mockito:mockito-core")
を削除します。
全ての変更後、Gradle Tool Window の左上にある「Refresh all Gradle projects」ボタンをクリックして更新します。
履歴
2019/01/06
初版発行。