【Java】Spring SecurityにCORS設定を追加する
![Thumbnail of post image 101](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
以下の記事で作成したSpring Securityを使用しWeb APIのリクエストごとにトークンで認証する処理にCORS設定を追加します。
【Spring】Spring Sec ...【Spring】MockMvc + AssertJでREST APIのテスト
![Thumbnail of post image 166](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
この記事ではSpring MVCの@RestControllerを使用し作成したREST APIのレスポンスをMockMVC使用してテストする際に、AssertJを使用してAP ...
【Spring】Mokitoを使って@RestControllerAdviceを使ったエラーハンドラのテストを行う
![Thumbnail of post image 059](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
Spring MVCでWeb APIを作成する場合@RestControllerAdviceを使ってエラーハンドラを作成することがあると思います。このエラーハンドラで想定通りに ...
【Spring】@RestControllerAdvice を使ってREST APIのエラーハンドラを作成する
![Thumbnail of post image 191](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
Spring MVCを使ってWeb APIを作成する際に、@RestControllerAdviceを使うことで共通のエラーハンドラを簡単に作成することができます。
【Spring】Spring Securityを使ってWeb APIの認証、認可を行う
![Thumbnail of post image 157](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
Spring MVCの@RestControllerを使って作成したWeb APIに対する認証、認可をリクエスト中のAuthorizationヘッダの値で行います。この認可はリクエストごとに行います。
実装方法の概要 ...【Spring】Mockit利用した単体テストの方法
![Thumbnail of post image 014](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
Mockitoとはテスト対象クラスが依存しているクラスを簡単にモック化する機能を提供しているライブラリです。mockit公式ページ
Mockitoを利用することでテスト対象クラスの単体テストに集中すること ...
【Spring】Lombokでコンストラクタインジェクションを簡潔に書く
![Thumbnail of post image 033](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
SpringではDIを行う際にはコンストラクタインジェクションを使用することが推奨されています。
テスト時にDIの対象クラスをモックオブジェクトに変更しやすい。DI対象のフィールド ...
Spring BootでMyBatis Generator のGradleプラグインを使用する
![Thumbnail of post image 060](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
MyBatis GeneratorをGradleのタスクとして実行するためのGradleプラグインです。 mybatis-generator-pluginこのプラグインを ...
【Spring Boot】 Bean ValidationをJUnitで単体テストする
![Thumbnail of post image 086](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
Java11
assertJ 3.15.0
テスト対象のコード
以下のBeanクラスのバリデーションをテスト対象とする。countに対する最小値チェックとtoとmessage ...
Spring Bean Validationで相関チェックを行う
![Thumbnail of post image 149](https://sebenkyo.com/wp/wp-content/uploads/2020/02/programming1-150x150.jpg)
Spring MVCにおいて@RestControllerを付与して作成したAPIへPOSTするリクエスト内で相関チェックを行いたい場合、リクエストのBean内に@Assert ...