序列化錯(cuò)誤
org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [com.atguigu.gulimall.authserver.vo.MemberResponseVo]
這里使用的spring-session存儲的,因?yàn)槭峭ㄟ^reids的,所以默認(rèn)需要序列化器,
解決方法:
1、我們在MemberResponseVo implement Searilizer (這個(gè)是二進(jìn)制流)
2、我們配置JSON的序列化器Bean
后續(xù)的錯(cuò)誤:
兩個(gè)微服務(wù)要取同一個(gè)session下的數(shù)據(jù),
首先你存入的數(shù)據(jù)VO模型必須要被兩個(gè)服務(wù)共享,這樣redis才能序列化、反序列化。
其次,使用模板引擎tyhmeleaf的時(shí)候,要先非空判斷,因?yàn)槟銊傞_始未登錄的是沒有data的,不判斷null就取值會報(bào)錯(cuò)的。

浙公網(wǎng)安備 33010602011771號