관리 메뉴

꿀맛코딩

Spring LocalDateTime response array로 내려올때 해결 방법 본문

공부방/Spring

Spring LocalDateTime response array로 내려올때 해결 방법

soycrab 2023. 10. 31. 01:13

어제까지만 해도 멀쩡하게 돌아가던 API가 Swagger 설정한다고,

이것저것 어노테이션 추가하다 보니.

막상 Swagger는 잘 돌아가는데 API 응답에서

LocalDateTime 값의 응답이 array로 내려오는 현상이 발견되었어요  ㅠ..

결국 App이 json값을 못 읽어 들이고, 빈 화면만 노출..

 

아래는 응답 값이에요. 

recentAt 값이 array로 들어오는걸 확인할 수 있어요.....

{"accountProfile":{"accountId":2041,"nickname":"감자",
"profileImage":null,
"latitude":37.5356821,"longitude":127.0921144,
enable":true,"aboutMe":null,"recentAt":[2023,10,31,0,56,4]}}

 

자 이제 다시 Spring으로 들아가서 바로 본론으로 들어가면 

아래 그림에서 파란색 선택된 

 

요녀석 때문이에요. 

@EnableWebFlux

 

이 녀석을 설정하면 Spring boot의 자동 구성이 비활성화가 되어서 그런다고 해요. 

저는 사용할 필요가 없어서 지웠지만, 만약 필요하다면 아래 고수님들의 도움을 받아서 수정해 보도록 하세요 ㅎ.

 

https://stackoverflow.com/questions/72932318/why-does-jackson-destructure-my-localdatetime-when-i-add-a-corsmapping-configura

 

Why does Jackson destructure my LocalDateTime when I add a CorsMapping configuration in Spring?

I have a simple API which handles Entity objects (shown below). @Data public class Entity { private LocalDateTime createdAt; } A controller which looks like the following: @RestController @

stackoverflow.com

 

 

반응형
Comments