Spring Boot で書籍の貸出状況確認・貸出申請する Web アプリケーションを作る ( 番外編 )( Spring Boot を 1.2.5 → 1.2.6 へバージョンアップ )
Spring Boot の 1.2.6 がリリースされたので、バージョンアップします。ついでにバージョンが最新でないライブラリを全部最新にします。
Spring Boot 1.2.6 へのバージョンアップ
現在 1.0.x-make-booklist ブランチで作業中なので、1.0.x をチェックアウトします。
IntelliJ IDEA 上で 1.0.x-upgrade-springboot-1.2.6 ブランチを作成します。
build.gradle を リンク先のその1、その2の内容 に変更します。
Gradle projects View の左上にある「Refresh all Gradle projects」ボタンをクリックして更新します。
Project View の External Libraries に表示される org.springframework.boot のライブラリのバージョンが 1.2.6.RELEASE になっていることを確認します。
Gradle projects View から clean タスクを実行します。
IntelliJ IDEA のメインメニューから「Build」-「Rebuild Project」メニューを選択して実行しモジュールをコンパイルし直しますが、一部のファイルでエラーが出るので修正します。
以下の2つのファイルの assertThatThrownBy の部分が赤い文字で表示されていました。
- src/test/java/ksbysample/webapp/lending/security/LendingUserDetailsServiceTest.java
- src/test/java/ksbysample/webapp/lending/service/calilapi/LendingUserDetailsServiceTest.java
assertThatThrownBy の部分にカーソルを移動してから Alt+Enter を押してコンテキストメニューを表示した後、「Static import methos...」を選択します。
Import 先の一覧が表示されるので「Assertions.assertThatThrownBy」を選択します。
import するパッケージが変更されたのが原因でしたので、問題が解消し assertThatThrownBy が黒い文字で表示されるようになります。
またファイルの上部の
import static org.assertj.core.api.StrictAssertions.assertThatThrownBy;
が残ったままになるので Ctrl+Alt+o を押して削除します。再度 IntelliJ IDEA のメインメニューから「Build」-「Rebuild Project」メニューを選択して実行し、モジュールをコンパイルし直します。今度は正常に終了します。
Project View のルートでコンテキストメニューを表示して「Run 'Tests in 'ksbysample...' with Coverage」を選択し、テストが全て成功することを確認します。
Gradle projects View から build タスクを実行し BUILD SUCCESSFUL が表示されることも確認します。
Gradle projects View から bootRun タスクを実行して Tomcat を起動した後、ブラウザから画面の動作に問題がないか確認します。確認後、Run View で Ctrl+F2 を押して Tomcat を停止します。
一部ソースの修正は必要でしたが、大きな問題は出なかったのでこのまま進めます。
commit、Push、Pull Request、マージ
- commit、GitHub へ Push、1.0.x-upgrade-springboot-1.2.6 -> 1.0.x へ Pull Request、1.0.x でマージ、1.0.x-upgrade-springboot-1.2.6 ブランチを削除、をします。
1.0.x-make-booklist ブランチをチェックアウトして rebase する
1.0.x-make-booklist ブランチの作業に戻ります。1.0.x-make-booklist をチェックアウトした後、以下のコマンドを実行します。
> git rebase 1.0.x ※エラーが出るので git status で問題のファイル ( build.gradle ) を確認後修正します > git add . > git rebase --continue ※再度エラーが出るので git status で問題のファイル ( build.gradle ) を確認後修正します > git add . > git rebase --continue
build.gralde を変更したので、念の為 Gradle projects View の左上にある「Refresh all Gradle projects」ボタンをクリックして更新しておきます。
以上で作業は完了です。
ソースコード
build.gradle
■その1
buildscript { ext { springBootVersion = '1.2.6.RELEASE' } repositories { jcenter() maven { url "http://repo.spring.io/repo/" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath("io.spring.gradle:dependency-management-plugin:0.5.3.RELEASE") // for Grgit classpath("org.ajoberstar:grgit:1.4.0") // Gradle Download Task classpath("de.undercouch:gradle-download-task:2.0.0") } }
- springBootVersion の値を 1.2.5.RELEASE → 1.2.6.RELEASE へ変更します。
- io.spring.gradle:dependency-management-plugin を 0.5.1.RELEASE → 0.5.3.RELEASE へ変更します。
- org.ajoberstar:grgit を 1.1.0 → 1.4.0 へ変更します。
- de.undercouch:gradle-download-task を 1.2 → 2.0.0 へ変更します。
■その2
dependencies { def jdbcDriver = "org.postgresql:postgresql:9.4-1203-jdbc41" // spring-boot-gradle-plugin によりバージョン番号が自動で設定されるもの // Appendix E. Dependency versions ( http://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html ) 参照 compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-thymeleaf") compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity3") compile("org.springframework.boot:spring-boot-starter-data-jpa") compile("org.springframework.boot:spring-boot-starter-velocity") compile("org.springframework.boot:spring-boot-starter-mail") compile("org.springframework.boot:spring-boot-starter-security") compile("org.springframework.boot:spring-boot-starter-redis") compile("org.codehaus.janino:janino") testCompile("org.springframework.boot:spring-boot-starter-test") // (ここから) gradle でテストを実行した場合に spring-security-test-4.0.2.RELEASE.jar しか classpath に指定されず // テストが失敗したため、3.2.8.RELEASE を明記している testCompile("org.springframework.security:spring-security-core:3.2.8.RELEASE") testCompile("org.springframework.security:spring-security-web:3.2.8.RELEASE") // (ここまで) ------------------------------------------------------------------------------------------------------ testCompile("org.springframework.security:spring-security-test:4.0.2.RELEASE") testCompile("org.yaml:snakeyaml") // spring-boot-gradle-plugin によりバージョン番号が自動で設定されないもの compile("${jdbcDriver}") compile("org.seasar.doma:doma:2.4.1") compile("org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16") compile("org.apache.commons:commons-lang3:3.4") compile("org.projectlombok:lombok:1.16.4") compile("com.google.guava:guava:18.0") compile("org.springframework.session:spring-session:1.0.1.RELEASE") compile("org.simpleframework:simple-xml:2.7.1") compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.2") compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.2") compile("com.univocity:univocity-parsers:1.5.6") testCompile("org.dbunit:dbunit:2.5.1") testCompile("com.icegreen:greenmail:1.4.1") testCompile("org.assertj:assertj-core:3.2.0") testCompile("com.jayway.jsonpath:json-path:2.0.0") testCompile("org.jmockit:jmockit:1.19") // for Doma-Gen domaGenRuntime("org.seasar.doma:doma-gen:2.4.1") domaGenRuntime("${jdbcDriver}") }
- org.postgresql:postgresql を 9.4-1201-jdbc41 → 9.4-1203-jdbc41 へ変更します。
- jdbc42 のライブラリも出ていたのですが、log4jdbc のライブラリが jdbc4.1 となっていたので jdbc41 を使うことにします。
- org.springframework.security:spring-security-core を 3.2.7.RELEASE → 3.2.8.RELEASE へ変更します。
- org.springframework.security:spring-security-test を 4.0.1.RELEASE → 4.0.2.RELEASE へ変更します。
- org.seasar.doma:doma を 2.3.1 → 2.4.1 へ変更します。
- org.projectlombok:lombok を 1.16.4 → 1.16.6 へ変更します。
- com.fasterxml.jackson.datatype:jackson-datatype-jsr310 を 2.6.1 → 2.6.2 へ変更します。
- com.fasterxml.jackson.dataformat:jackson-dataformat-xml を 2.5.3 → 2.6.2 へ変更します。
compile("com.univocity:univocity-parsers:1.5.6")
を追加します。- org.assertj:assertj-core を 3.1.0 → 3.2.0 へ変更します。
- org.seasar.doma:doma-gen を 2.3.1 → 2.4.1 へ変更します。