Spring解体新書第二版をhands onでやりました。
Spring/SpringBootはやっていた当時の最新バージョンを使っているため、
本のサンプルコードと異なるコードになっている部分があります。
- Java OpenJDK17
- SpringBoot v2.7.0
バージョンアップにより、application.propertiesの記述方法が変わっています。
詳しくは以下に書いています。
java16から正式リリースされたRecordを使用して一部のクラスを記述しています。
具体的には以下の2クラス
これに伴い、ModelMapper
の設定を一部変えています。
詳しくは以下にまとめています。
SpringSecurity5.7からWebSecurityConfigurerAdapter
がdeprecatedになって、本で記載されている書き方が非推奨となりました。
これで、SecurityConfigを書き直しています。
大きな変更点は以下
WebSecurityConfigurerAdapter
の継承をやめたconfigure(WebSecurity)
->WebSecurityCustomizer
のBean登録configure(HttpSecurity)
->SecurityFilterChain
のBean登録configure(AuthenticationManagerBuilder)
->InMemoryUserDetailsManager
のBean登録(インメモリの場合)configure(AuthenticationManagerBuilder)
->UserDetailsManager
のBean登録- 上記に伴い不要となった
UserDetailsServiceImpl
の削除 - 以下の記事にまとめています
- 上記に伴い不要となった