Backend
home

[Spring] 스프링 3.3에서 추가된 ‘pageSerializationMode = VIA_DTO’

생성일
2025/01/24 05:52
태그
SpringBoot
최종 편집 일시
2025/01/24 05:52
페이지네이션 구현 과정에서 다음과 같은 로그가 보였다.
2024-08-26T15:13:27.588+09:00 WARN 63105 --- [todo] [nio-8080-exec-2] 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.
Java
복사
확인해보니 Page 인터페이스 직렬화 문제로 인해 새로 들어온 스펙이라고 한다.
적용 전
{ "totalPages": 5, "totalElements": 14, "number": 0, "sort": { "empty": true, "sorted": false, "unsorted": true }, "first": true, "last": false, "size": 3, "content": [ { "id": 14, "title": "asd55", "contents": "12312355", "commentCount": 0, "createdAt": "2024-08-26T15:03:39.517338", "modifiedAt": "2024-08-26T15:03:39.517338", "username": "가나ㅁㅁㅁ" }, { "id": 13, "title": "asd55", "contents": "12312355", "commentCount": 0, "createdAt": "2024-08-26T15:03:37.939738", "modifiedAt": "2024-08-26T15:03:37.939738", "username": "가나" }, { "id": 12, "title": "asd55", "contents": "12312355", "commentCount": 0, "createdAt": "2024-08-26T15:03:37.255681", "modifiedAt": "2024-08-26T15:03:37.255681", "username": "가나" } ], "numberOfElements": 3, "pageable": { "pageNumber": 0, "pageSize": 3, "sort": { "empty": true, "sorted": false, "unsorted": true }, "offset": 0, "paged": true, "unpaged": false }, "empty": false }
Java
복사
적용 후 (page 관련 정보에서 보여지는 형태에 차이가 있음)
{ "content": [ { "id": 14, "title": "asd55", "contents": "12312355", "commentCount": 0, "createdAt": "2024-08-26T15:03:39.517338", "modifiedAt": "2024-08-26T15:03:39.517338", "username": "가나ㅁㅁㅁ" }, { "id": 13, "title": "asd55", "contents": "12312355", "commentCount": 0, "createdAt": "2024-08-26T15:03:37.939738", "modifiedAt": "2024-08-26T15:03:37.939738", "username": "가나" }, { "id": 12, "title": "asd55", "contents": "12312355", "commentCount": 0, "createdAt": "2024-08-26T15:03:37.255681", "modifiedAt": "2024-08-26T15:03:37.255681", "username": "가나" } ], "page": { "size": 3, "number": 0, "totalElements": 14, "totalPages": 5 } }
Java
복사