默认的配置在RedisHttpSessionConfiguration
默认使用defaultRedisSerializer
其注入点
@Configuration
class SessionConfig {
@Bean
fun springSessionDefaultRedisSerializer(): RedisSerializer<Any>{
val om = ObjectMapper().also {
it.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY)
it.activateDefaultTyping(
LaissezFaireSubTypeValidator.instance,
ObjectMapper.DefaultTyping.NON_FINAL,
JsonTypeInfo.As.PROPERTY
)
it.registerKotlinModule()
}
return Jackson2JsonRedisSerializer(Any::class.java).also { it.setObjectMapper(om) }
}
}
写个配置,不要改方法名,有@Qualifier约束。