Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 일정관리프로젝트
- Redis
- mysql
- spring boot
- Lv.0
- 알고리즘
- LV1
- S3
- 코테
- LV0
- LV02
- 이것이 자바다
- CoffiesVol.02
- LV.02
- 배열
- JPA
- LV03
- 디자인 패턴
- 연습문제
- 프로그래머스
- 일정관리 프로젝트
- Join
- SQL
- 데이터 베이스
- Til
- GIT
- LV01
- docker
- Java
- 포트폴리오
Archives
- Today
- Total
코드 저장소.
[Spring boot] Page Interface의 직렬화 본문
목차
1. 문제 상황
2.해결책
1. 문제 상황
일정 프로젝트를 진행을 하면서 아래와 같은 경고 문구가 나왔다.
2025-01-27 18:15:42 [http-nio-8082-exec-2] [f88939bd-064c-4a9f-916c-14a228ece179] [] WARN o.s.d.w.c.SpringDataJacksonConfiguration$PageModule$WarningLoggingModifier - 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.
그리고 컨트롤러 부분은 다음과 같다.
@GetMapping("/page")
public ResponseEntity<Page<MemberResponse>> findAllPage(@PageableDefault Pageable pageable) {
Page<MemberResponse> memberPageList = memberInConnector.findAll(pageable);
logger.info("memberList::" + memberPageList);
return ResponseEntity.status(HttpStatus.OK).body(memberPageList);
}
데이터를 출력을 하는데 있어서는 문제는 없지만 이러한 경고 문구가 나온 이유는 페이징 구현이 직렬화되지 않아
JSON 형식의 body에 안정성이 없다는 것이 이 오류의 원인이다.
2.해결책
해결책은 의외로 간단하다. 메인 메서드 부분에 아래의 코드처럼 작성을 하면 경고 문구는 사라진다.
@EntityScan(basePackages = "com.example")
@EnableJpaRepositories(basePackages = "com.example")
@SpringBootApplication(scanBasePackages = "com.example")
@EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO)
public class BootStrapApplication {
public static void main(String[] args) {
SpringApplication.run(BootStrapApplication.class, args);
}
}
'포폴 > 일정관리앱' 카테고리의 다른 글
OpenFeign를 활용해서 일정추천기능 만들기. (0) | 2025.04.05 |
---|---|
AWS S3 Presigned URL을 이용한 업/다운로드 구현 (0) | 2025.04.04 |
첨부파일에 관련된 로직의 고찰 (0) | 2025.03.23 |
System.out.println()을 쓰면 안 되는 이유 (0) | 2025.03.23 |
멀티모듈을 도입을 하는 이유 (0) | 2025.02.03 |