Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring Boot 1.5→2.1バージョンアップを経験して分かったハマりどころ

Spring Boot 1.5→2.1バージョンアップを経験して分かったハマりどころ

JSUG勉強会2020 その2

kawakawaryuryu

February 12, 2020
Tweet

More Decks by kawakawaryuryu

Other Decks in Programming

Transcript

  1. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 2020年2⽉12⽇

    JSUG勉強会 2020その2 川⼝ ⻯太郎(@kawakawaryuryu) Spring Boot 1.5→2.1 バージョンアップを経験して 分かったハマりどころ
  2. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. ⾃⼰紹介

    2 • 川⼝ ⻯太郎(かわぐち りゅうたろう) • 所属: ヤフー株式会社 システム統括本部 情報システム本部 • お仕事: 社内ワークフローシステムの開発 • 普段使っている技術 • Spring Boot(Java) • Angular(TypeScript) • Express(Node.js) • Cloud Foundry • Spring歴: 2年半ほど @kawakawaryuryu
  3. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 今⽇お話すること

    3 • Boot 1.5→2.1に上げた1事例のお話 • バージョンアップの流れ • 気をつけたことなども紹介 • Boot 2系に上げた時のハマりポイント • 実際に起きたエラーごとに紹介 • バージョンアップを振り返ってみて
  4. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 今⽇お話する技術

    4 • Spring Data Jpa • Spring Web Mvc • Mockito • Jackson • Bean Override • UriComponentsBuilder • spring-boot-properties-migrator • (Spring Boot Actuator)
  5. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 前提

    5 • Spring Boot 1.5.14→2.1.6 • Mavenで紹介します • スクラム開発で進めている
  6. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. バージョンアップの流れ

    6 1. Spring Boot 2系変更点調査 2. コード修正 3. コードレビュー 4. 動作確認 ×リポジトリ数
  7. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 1.

    Spring Boot 2系変更点調査 7 • 2h使ってSpring Bootの変更点をざっと 調査 • Migration Guide • Release Note • 試しにバージョンアップしてコンパイルやテ ストを実⾏してエラー内容をざっと把握する バージョンアップコストを把握する
  8. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 2.

    コード修正 8 • 実際にSpring Bootバージョンアップを⾏う • 詳しくは後ほど • ⼩さいリポジトリから対応 →実績を積んでいく • 1スプリントに詰め込みすぎない • ⼀気にやると当初の計画からオーバーしがち
  9. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 3.

    コードレビュー 9 • チームメンバーにレビュー依頼 • 変更点が多くレビュアーが⾟い モブレビューでレビュー のコストを下げる
  10. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 4.

    動作確認 10 • ⼿動によるリグレッションテストを実施 • デグレが起こっていないか確認 • シナリオテストを実施 • ⼀連の動作に問題ないか確認 網羅的に品質を担保
  11. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Copyright

    (C) 2019 Yahoo Japan Corporation. All Rights Reserved. コード修正の 具体的な流れと ハマりどころの紹介
  12. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. コード修正の流れ

    12 1. Spring Bootのバージョン修正 2. コンパイル→エラーをひたすら修正 3. テスト→エラーをひたすら修正 4. Spring Boot起動 5. 動作確認
  13. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 1.

    Spring Bootのバージョン修正 13 • 修正前 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> </parent> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.14.RELEASE</version> </parent> • 修正後
  14. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. コンパイルの前に

    15 maven-compiler-pluginを設定してwarningと ⾮推奨ログを表⽰するようにしておくと便利 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation> </configuration> </plugin> </plugins> </build>
  15. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. コンパイルエラー①

    16 $ mvn compile [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … [ERROR] /jsug-demo/src/main/java/com/kawakawaryuryu/boot15/demo/service/SampleService.java:[47,47] インタ フェース org.springframework.data.repository.query.QueryByExampleExecutor<T>のメソッド findOneは指定された型に適 用できません。 期待値: org.springframework.data.domain.Example<S> 検出値: java.lang.String 理由: 型変数Sを推論できません (引数の不一致: java.lang.Stringをorg.springframework.data.domain.Example<S>に変換できません:)
  16. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. コンパイルエラー①

    17 $ mvn compile [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … [ERROR] /jsug-demo/src/main/java/com/kawakawaryuryu/boot15/demo/service/SampleService.java:[47,47] インタ フェース org.springframework.data.repository.query.QueryByExampleExecutor<T>のメソッド findOneは指定された型に適 用できません。 期待値: org.springframework.data.domain.Example<S> 検出値: java.lang.String 理由: 型変数Sを推論できません (引数の不一致: java.lang.Stringをorg.springframework.data.domain.Example<S>に変換できません:)
  17. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. findOne(Spring

    Data Jpa) Boot 1.5 (Spring Data Jpa 1.11) 18 Boot 2.0 (Spring Data Jpa 2.0) • QBE(Query By Example)のみになった SampleEntity entity = sampleRepository.findOne("1"); SampleEntity probe = SampleEntity .builder() .id("1") .build(); Example<SampleEntity> example = Example.of(probe); SampleEntity entity = sampleRepository.findOne(example); SampleEntity probe = SampleEntity .builder() .id("1") .build(); Example<SampleEntity> example = Example.of(probe); Optional<SampleEntity> entity = sampleRepository.findOne(example);
  18. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. その他メソッド(Spring

    Data Jpa) Boot 1.5 (Spring Data Jpa 1.11) 19 Boot 2.0 (Spring Data Jpa 2.0) Optional<SampleEntity> entity = sampleRepository.findById("1"); boolean exists = sampleRepository.existsById("1"); sampleRepository.deleteById("1"); sampleRepository.saveAll(sampleEntityList); • Primary key指定のメソッドは~ByIdに変更 SampleEntity entity = sampleRepository.findOne("1"); boolean exists = sampleRepository.exists("1"); sampleRepository.delete("1"); sampleRepository.save(sampleEntityList);
  19. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Warning①

    20 $ mvn compile [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … [WARNING] /jsug-demo/src/main/java/com/kawakawaryuryu/boot15/demo/config/WebMvcConfig.java:[5,57] org.springframework.web.servlet.config.annotationの org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapterは非推奨になりました
  20. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. WebMvcConfigurerAdapterが⾮推奨

    Boot 1.5(Spring 4.3) 21 Boot 2.0(Spring 5.0) @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { } @Configuration public class WebMvcConfig implements WebMvcConfigurer { } • WebMvcConfigurer(インターフェース)に変更 • WebMvcConfigurerがdefaultメソッドで持つようになった
  21. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Warning②

    22 $ mvn test-compile … [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo --- … [WARNING] /jsug-demo/src/test/java/com/kawakawaryuryu/boot15/demo/service/SampleServiceTest.java:[59,44] org.mockito.Matchersの<T>anyListOf(java.lang.Class<T>)は非推奨になりました
  22. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テスト対象コード例

    23 @Service // テスト対象コード例 public class SampleService { private final DependencyService dependencyService; public SampleService( DependencyService dependencyService) { this.dependencyService = dependencyService; } public void sampleList(List<String> list) { dependencyService.callList(list); }
  23. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. ⼀部Matcherメソッドが⾮推奨

    Boot 1.5(Mockito 1) 24 Boot 2.0(Mockito 2) @Test public void testSampleList() { List<String> list = Arrays.asList("hoge", "fuga"); sampleService.sampleList(list); verify(dependencyService) .callList(anyListOf(String.class)); } @Test public void testSampleList() { List<String> list = Arrays.asList("hoge", "fuga"); sampleService.sampleList(list); verify(dependencyService) .callList(anyList()); } • anyXXOf(SomeType.class)が⾮推奨に • Java8から型推論してくれる
  24. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー①

    26 $ mvn test [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … java.lang.IllegalStateException: Failed to load ApplicationContext … Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException … Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException
  25. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー①

    27 $ mvn test [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … java.lang.IllegalStateException: Failed to load ApplicationContext … Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException … Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException
  26. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. InvalidDefinitionException

    28 • Jackson 2.9から追加されたクラス <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.11</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.8</version> </dependency> Boot 1.5 Boot 2.0
  27. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. spring-boot-starter-json

    29 <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jdk8</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-parameter-names</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> </dependency> Boot 2から新設
  28. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー②

    30 $ mvn test [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … java.lang.IllegalStateException: Failed to load ApplicationContext … Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'mappedInterceptor' defined in com.kawakawaryuryu.boot15.demo.config.AppTestConfig: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appTestConfig; factoryMethodName=mappedInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in com.kawakawaryuryu.boot15.demo.config.AppTestConfig] for bean 'mappedInterceptor': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=mappedInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/kawakawaryuryu/boot15/demo/config/AppConfig.class]] bound.
  29. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー②

    31 $ mvn test [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- … java.lang.IllegalStateException: Failed to load ApplicationContext … Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'mappedInterceptor' defined in com.kawakawaryuryu.boot15.demo.config.AppTestConfig: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appTestConfig; factoryMethodName=mappedInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in com.kawakawaryuryu.boot15.demo.config.AppTestConfig] for bean 'mappedInterceptor': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=mappedInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/kawakawaryuryu/boot15/demo/config/AppConfig.class]] bound.
  30. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 例

    32 @Configuration public class AppConfig { @Bean public MappedInterceptor mappedInterceptor() { return new MappedInterceptor(new String[]{"/sample"}, new SampleInterceptor()); } } @TestConfiguration public class AppTestConfig { @Bean public MappedInterceptor mappedInterceptor() { return new MappedInterceptor(new String[]{"/**"}, new String[]{"/**"}, new SampleInterceptor()); } } Beanを Overrideして 書き換えている
  31. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Bean

    Override禁⽌ 33 • Boot 2.1からBean Overrideはデフォルトで 禁⽌ • 有効にしたい場合は application.yml/propertiesを下記のように する • 基本的にはfalseにしたほうがいい spring: main: allow-bean-definition-overriding: true
  32. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー③

    34 $ mvn test [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo --- … [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.532 s <<< FAILURE! - in com.kawakawaryuryu.boot15.demo.service.SampleServiceTest [ERROR] testSampleString(com.kawakawaryuryu.boot15.demo.service.SampleServiceTest) Time elapsed: 0.016 s <<< FAILURE! org.mockito.exceptions.verification.junit.ArgumentsAreDifferent: Argument(s) are different! Wanted: dependencyService.callString(<any string>); -> at com.kawakawaryuryu.boot15.demo.service.SampleServiceTest.testSampleString(SampleServiceTest.java:45) Actual invocation has different arguments: dependencyService.callString(null); -> at com.kawakawaryuryu.boot15.demo.service.SampleService.sampleString(SampleService.java:26) at com.kawakawaryuryu.boot15.demo.service.SampleServiceTest.testSampleString(SampleServiceTest.java:45)
  33. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー③

    35 $ mvn test [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo --- … [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.532 s <<< FAILURE! - in com.kawakawaryuryu.boot15.demo.service.SampleServiceTest [ERROR] testSampleString(com.kawakawaryuryu.boot15.demo.service.SampleServiceTest) Time elapsed: 0.016 s <<< FAILURE! org.mockito.exceptions.verification.junit.ArgumentsAreDifferent: Argument(s) are different! Wanted: dependencyService.callString(<any string>); -> at com.kawakawaryuryu.boot15.demo.service.SampleServiceTest.testSampleString(SampleServiceTest.java:45) Actual invocation has different arguments: dependencyService.callString(null); -> at com.kawakawaryuryu.boot15.demo.service.SampleService.sampleString(SampleService.java:26) at com.kawakawaryuryu.boot15.demo.service.SampleServiceTest.testSampleString(SampleServiceTest.java:45)
  34. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テスト対象コード例

    36 @Service // テスト対象コード例 public class SampleService { private final DependencyService dependencyService; public SampleService( DependencyService dependencyService) { this.dependencyService = dependencyService; } public void sampleString(String value) { dependencyService.callString(value); } public void sampleObject(SampleType sampleType) { dependencyService.callSampleType(sampleType); } }
  35. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. ⼀部Matcherのnon

    null化 Boot 1.5(Mockito 1) 37 Boot 2.0(Mockito 2) @Test public void testSampleString() { sampleService.sampleString(null); verify(dependencyService) .callString(anyString()); } @Test public void testSampleObject() { sampleService.sampleObject(null); verify(dependencyService) .callSampleType(any(SampleType.class)); } @Test public void testSampleString() { sampleService.sampleString(null); verify(dependencyService) .callString(isNull()); } @Test public void testSampleObject() { sampleService.sampleObject(null); verify(dependencyService) .callSampleType(any()); } • anyXX(), any(SomeType.class)はnull禁⽌ • nullの場合はisNull()かany()を使う • 引数がnullableなのか再度⾒直す
  36. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テストエラー④

    38 • クエリパラメータが エンコードされなくなったエラー [ERROR] testGetSample(com.kawakawaryuryu.boot15.demo.client.SampleClientTest) Time elapsed: 0.025 s <<< FAILURE! java.lang.AssertionError: Request URI expected:</sample?q=%2Bhoge> but was:</sample?q=+hoge> at com.kawakawaryuryu.boot15.demo.client.SampleClientTest.testGetSample(SampleClientTest.java:28)
  37. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. URLの予約⽂字エンコード

    39 • 予約⽂字をURLに使⽤するときは %エンコードする • 例: /sample?query=+hoge → /sample?query=%2Bhoge RFC: https://tools.ietf.org/html/rfc3986
  38. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. UriComponentsBuilder

    Boot 1.5 40 Boot 2.0 URI uri = UriComponentsBuilder.fromPath("/sample") .queryParam("q", "+hoge") .build() .encode() .toUri(); • クエリパラメータのエンコー ドはuri変数で指定して展開 時にエンコードする URI uri = UriComponentsBuilder.fromPath("/sample") .queryParam("q", "{q}") .encode() .buildAndExpand("+hoge") .toUri(); // or URI uri = UriComponentsBuilder.fromPath("/sample") .queryParam("q", "{q}") .build("+hoge");
  39. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 4.

    Spring Boot起動 41 $ mvn spring-boot:run
  40. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Spring

    Boot起動の前に 42 • spring-boot-properties-migratorを⼊れよう • Boot 1.5→Boot 2.0の application.yml/propertiesの変更を⼿助けして くれるツール • Boot 1.5の書き⽅だと実⾏時にWarningを吐く • Boot 1.5の書き⽅でも動くようにしてくれる • propertiesの変更完了後このモジュールは削除する <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-properties-migrator</artifactId> <scope>runtime</scope> </dependency>
  41. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 例:

    Spring Boot Actuator 43 2020-02-05 01:13:58.997 WARN 67638 --- [ main] o.s.b.c.p.m.PropertiesMigrationListener : The use of configuration keys that have been renamed was found in the environment: Property source 'applicationConfig: [classpath:/application.yml]': Key: endpoints.enabled Line: 2 Replacement: management.endpoints.enabled-by-default Key: endpoints.health.enabled Line: 4 Replacement: management.endpoint.health.enabled Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys. endpoints: enabled: false health: enabled: true management: endpoints: enabled-by-default: false endpoint: health: enabled: true Boot 1.5 Boot 2.0
  42. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. コード修正振り返って

    44 • Spring Data Jpa互換性なしの変更 • WebMvcConfigurerAdapter⾮推奨 • Mockito⾊々⾮推奨、変更 • spring-boot-starter-json新設 • Bean Override禁⽌ • クエリパラメータのエンコード⽅法変更 • spring-boot-properties-migrator便利
  43. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 全体を振り返って

    45 • 事前の調査と⼩さいリポジトリから対応したことにより、 ⾒積もりを⼤きく外れることはなかった • 徐々に対応することで他のタスクに⽀障はなかった • テストをしっかり書いていたので素早くエラーに気づけた • @SpringBootTestによる結合テスト⼤事 • Release NoteとMigration Guideはちゃんと読む • PRは⼩さくこまめに出す • E2Eテスト⾃動化までできると動作確認のコストを減らせ たかも
  44. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Copyright

    (C) 2019 Yahoo Japan Corporation. All Rights Reserved. ご清聴ありがとう ございました
  45. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Copyright

    (C) 2019 Yahoo Japan Corporation. All Rights Reserved. その他エラー Warning
  46. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Warning③

    48 $ mvn test-compile … [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo --- … [WARNING] /jsug-demo/src/test/java/com/kawakawaryuryu/boot15/demo/service/SampleServiceTest.java:[26,27] org.mockito.runnersのorg.mockito.runners.MockitoJUnitRunnerは非推奨になりました
  47. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. MockitoJUnitRunner

    Boot 1.5(Mockito 1) 49 Boot 2.0(Mockito 2) import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SampleServiceTest { } import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SampleServiceTest { } • org.mockito.runners.MockitoJUnitRunner がDeprecated • Mockito 3から削除
  48. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Warning④

    50 $ mvn test-compile … [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo --- … [WARNING] /jsug-demo/src/test/java/com/kawakawaryuryu/boot15/demo/service/SampleServiceTest.java:[10,26] org.mockitoのorg.mockito.Matchersは非推奨になりました
  49. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Matchers

    Boot 1.5(Mockito 1) 51 Boot 2.0(Mockito 2) import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; // or import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.eq; • org.mockito.Matchers.*がDeprecated • Mockito 3から削除
  50. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. テスト(落ちないけど吐かれる)エラー⑤

    52 • H2 Database Engine • trace.db/h2datasource.trace.db 2020-01-16 00:09:52 JDBCX: exception org.h2.jdbc.JdbcSQLException: 機能はサポートされていません: "isWrapperFor" Feature not supported: "isWrapperFor" [50100-192] at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.get(DbException.java:179) at org.h2.message.DbException.get(DbException.java:155) at org.h2.message.DbException.getUnsupportedException(DbException.java:216) at org.h2.message.TraceObject.unsupported(TraceObject.java:375) at org.h2.jdbcx.JdbcDataSource.isWrapperFor(JdbcDataSource.java:422) at org.springframework.boot.jdbc.DataSourceUnwrapper.safeUnwrap(DataSourceUnwrapper.java:77) …
  51. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. isWrapperFor

    53 • H2の1.4.197からisWrapperFor メソッドがJdbcDataSourceに追加 • Boot 2.1の依存するH2は1.4.199 Spring Boot Spring JDBC H2 1.5.14 4.3.18 1.4.193 2.1.6 5.1.8 1.4.199
  52. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. H2をバージョンアップ

    Boot 1.5 54 Boot 2.1 <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.193</version> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.199</version> </dependency> エラー吐かれなくなった︕
  53. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. Qiita書きました

    55 • Spring Boot 2系にバージョンアップしたらH2 がエラーを吐き出したときの対処 • Spring Boot 1.5→2系バージョンアップ時の Mockito1系→2系の修正内容を取り上げてみた
  54. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 参考

    56 • https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0- Migration-Guide • https://github.com/spring-projects/spring-boot/wiki/spring-boot-2.0-release- notes • https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release- Notes • https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2 • https://docs.spring.io/spring/docs/5.0.8.BUILD-SNAPSHOT/spring-framework- reference/web.html • http://www.h2database.com/html/changelog.html