| | |
| | | import com.fasterxml.jackson.annotation.PropertyAccessor; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; |
| | | import com.qianwen.mdc.collect.config.redis.RedisKeySerializer; |
| | | |
| | | import org.springframework.cache.annotation.CachingConfigurerSupport; |
| | | import org.springframework.cache.annotation.EnableCaching; |
| | |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.data.redis.core.ZSetOperations; |
| | | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
| | | import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; |
| | | import org.springframework.data.redis.serializer.RedisSerializer; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | |
| | | //Jackson2JsonRedisSerializer<Object> jacksonSeial = new Jackson2JsonRedisSerializer<>(Object.class); |
| | | ObjectMapper om = new ObjectMapper(); |
| | | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
| | | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
| | | |
| | | //om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
| | | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); |
| | | //om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL,JsonTypeInfo.As.WRAPPER_ARRAY); |
| | | |
| | | |
| | | jacksonSeial.setObjectMapper(om); |
| | | template.setValueSerializer(jacksonSeial); |
| | | template.setKeySerializer(new StringRedisSerializer()); |
| | | template.setHashKeySerializer(new StringRedisSerializer()); |
| | | |
| | | //template.setKeySerializer(new StringRedisSerializer()); //这个注释了1024 |
| | | RedisKeySerializer keySerializer = new RedisKeySerializer(); |
| | | template.setKeySerializer(keySerializer); |
| | | template.setHashKeySerializer(keySerializer); |
| | | |
| | | |
| | | //ClassLoader classLoader = getClass().getClassLoader(); |
| | | //template.setHashKeySerializer(new JdkSerializationRedisSerializer(classLoader)); |
| | | template.setHashValueSerializer(jacksonSeial); |
| | | template.afterPropertiesSet(); |
| | | return template; |