Skip to content

fix: PageImpl의 직렬화 문제 #148

@mete0rfish

Description

@mete0rfish

🔥 구현 기능

Spring Boot 3.3으로 오면서 PageImpl 클래스가 도메인 객체이기 때문에 직렬화하는 것을 권장하지 않는다는 WARNING 문구가 뜬다.
Page<> 대신 PagedModel<>를 사용하는 것을 권장한고 있다.

PageModule$PlainPageSerializationWarning : Serializing PageImpl instances as-is is not supported, meaning that there is no guarantee about the stability of the resulting JSON structure!
	For a stable JSON structure, please use Spring Data's PagedModel (globally via @EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO))
	or Spring HATEOAS and Spring Data's PagedResourcesAssembler as documented in https://docs.spring.io/spring-data/commons/reference/repositories/core-extensions.html#core.web.pageables.

적용 주의 사항

각 객체들이 반환하는 JSON 필드가 달라진다.
결론적으로 더 간단해지기에 프론트엔드 입장에서 더 사용하기 편할 것으로 예측된다.

Page<>

{
  "content": [/* 데이터들... */],
  "pageable": {
    "pageNumber": 1,
    "pageSize": 10,
    "sort": [],
    "offset": 10,
    "paged": true,
    "unpaged": false
  },
  "last": false,
  "totalElements": 228,
  "totalPages": 23,
  "first": false,
  "size": 10,
  "number": 1,
  "sort": [],
  "numberOfElements": 10,
  "empty": false
}

PagedModel<>

{
  "content": [/* 데이터들... */],
  "page": {
    "size": 10,
    "number": 1,
    "totalElements": 228,
    "totalPages": 23
  }
}

🚧 작업목록

  • �Page 대신 PagedModel로 변경

⏰ 추정 시간

1시간

🔗 관련 링크

Page 리펙터링

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions