Skip to content

Commit

Permalink
fix: format
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoiEungi committed Dec 10, 2023
1 parent 5073e47 commit aebd0e2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions _posts/2023-12-10-spring-redis-cache-serialization-exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

layout: post

title: Spring Boot에서 Redis @Cacheable을 사용할 때 주의할 점
title: Spring Boot에서 Redis @Cacheable을 사용할 때 주의할 점

tags: [Spring Boot, Redis]

Expand Down Expand Up @@ -118,11 +118,9 @@ public class ProductController {

해당 코드에서 getTenProduct()를 먼저 호출하면 다음과 같은 응답이 오며 redis에 잘 쌓이게 됩니다.

<img src="https://i.imgur.com/yGBPAuN.png" width=400px, height=400px>
![](https://i.imgur.com/yGBPAuN.png)



<img src="https://i.imgur.com/s6JUDmM.png" width=400px, height=400px>
![](https://i.imgur.com/s6JUDmM.png)



Expand All @@ -133,7 +131,7 @@ public class ProductController {

이후 ProductResponse를 v2 패키지로 변경한 이후 어플리케이션을 재실행해서 동일한 API를 호출하면 SerializationException이 발생합니다.

``` // package com.example.redisinactions.api.v2;
``` java
// package com.example.redisinactions.api.v2;
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
Expand All @@ -146,11 +144,11 @@ public class ProductResponse implements Serializable {
![](https://i.imgur.com/KlKjpgm.png)

Exception의 cause를 확인해보면 `ClassNotFountException`이 발생합니다. `com.example.redisinactions.api.ProductResponse` 클래스를 역직렬화해야 하는데 해당 클래스가 `com.example.redisinactions.api.v2.ProductResponse`로 변경되어 발생한 현상입니다.
```

``` java
Caused by: java.lang.ClassNotFoundException: com.example.redisinactions.api.ProductResponse
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
...
```

![](https://i.imgur.com/whlF2nJ.png)
Expand Down

0 comments on commit aebd0e2

Please sign in to comment.