상세 컨텐츠

본문 제목

[Kotlin] Deprecated - ObjectMapper.DefaultTyping.EVERYTHING

Troubleshooting

by 발발개발 2025. 2. 13. 14:01

본문

ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] -- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.data.redis.serializer.SerializationException: Could not read JSON:Could not resolve subtype of [simple type, class java.lang.Object]: missing type id property '@class'
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 384] ] with root cause
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class java.lang.Object]: missing type id property '@class'
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 384]

 

 

1. Kotlin data class - Redis Cache 직렬화/역직렬화 과정 중 class type에 대한 정보가 포함되지 않는 이슈 발생

 

2. ObjectMapper.DefaultTyping.EVERYTHING 사용하여 해결했지만, Deprecated Since 2.17 and removed from 3.0

 

3. 관련 자료 검색

 

4. 주관적 결론

  • Kotin data class는 Redis Cache 직렬화/역직렬화 과정에 class type에 대한 정보를 포함하기 위해 ObjectMapper.DefaultTyping.EVERYTHING 사용이 필수적임
  • JsonTypeInfo annotation과 Wrapper class 사용하여 직렬화/역직렬화를 할 수 있지만, 좋은 방향이 아니라고 판단
  • ObjectMapper.DefaultTyping.EVERYTHING 사용 유지 결정 및 추후 라이브러리 버전에 따른 업데이트 사항 팔로잉

댓글 영역