11/2/2026, 9:31:21 AM

Spring Boot 4 にしたら 400 Bad Request が出るようになった

複数コンストラクタを持つ request dto で パラメータを持つコンストラクタを呼び出し、エラーになっていた。
@JsonCreator でデシリアライズするコンストラクタを明示する。
Lombok の @NoArgsConstructor を使っていた場合は、 @NoArgsConstructor(onConstructor_ = @JsonCreator) と明示する。

ログが表示されないので何が起きているか気づけない。
ResponseEntityExceptionHandler を継承したクラスを作り handleHttpMessageNotReadable メソッドを Override すればロギングを追加できる。

@Override
protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers,
                                                              HttpStatusCode status, WebRequest request) {
    log.warn("うおおおおお", ex);
    return super.handleHttpMessageNotReadable(ex, headers, status, request);
}
TweetBlueskyLike