레디스로 캐싱 기능 구현중 java.io.NotSerializableException 오류 발생

 

 

해결 방안 

1.  애플리케이션 클래스에 @EnableSpringDataWebSupport 추가 

@EnableFeignClients
@SpringBootApplication
@EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO)
public class OrderApplication {

	public static void main(String[] args) {
		SpringApplication.run(OrderApplication.class, args);
	}

}

 

2. 엔티티랑 Dto에 Serializable 임플리먼트

@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderResponseDto implements Serializable {
    private Long order_id;
    private List<Long> productIds;

    public OrderResponseDto(Order order) {
        this.order_id = order.getOrder_id();
        this.productIds = order.getProductIds();
    }
}

'스프링 심화 TIL' 카테고리의 다른 글

캐싱 전략  (0) 2024.08.13
Could not write JSON: failed to lazily initialize a collection of role  (0) 2024.08.11
@ElementCollection  (0) 2024.08.08
정수 내림차순으로 배치하기  (0) 2024.08.08
MSA Spring Cloud  (0) 2024.08.06

+ Recent posts