private void setSerializer(StringRedisTemplate template) { Jackson2JsonRedisSerializer jackson2JsonRedisSerializer =new Jackson2JsonRedisSerializer(Object.class); ObjectMapper obm =new ObjectMapper(); obm.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); obm.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); jackson2JsonRedisSerializer.setObjectMapper(obm); template.setValueSerializer(jackson2JsonRedisSerializer);