| | |
| | | //package com.ruoyi.doublePrevention.config.redis; |
| | | // |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | //import org.springframework.data.redis.connection.RedisConnectionFactory; |
| | | //import org.springframework.data.redis.core.RedisTemplate; |
| | | //import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; |
| | | //import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | // |
| | | //@Configuration |
| | | //public class RedisConfig { |
| | | // |
| | | // |
| | | // |
| | | // /** |
| | | // * @Description: key和value的序列化方式 |
| | | // */ |
| | | // @Bean |
| | | // public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { |
| | | // |
| | | // RedisTemplate<String, Object> template = new RedisTemplate<>(); |
| | | // template.setConnectionFactory(factory); |
| | | // // json序列化对象 |
| | | // GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer(); |
| | | // StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); |
| | | // // key=>string |
| | | // template.setKeySerializer(stringRedisSerializer); |
| | | // // hash=>string |
| | | // template.setHashKeySerializer(stringRedisSerializer); |
| | | // // value=>json |
| | | // template.setValueSerializer(jackson2JsonRedisSerializer); |
| | | // // hashValue=>json |
| | | // template.setHashValueSerializer(jackson2JsonRedisSerializer); |
| | | // // set |
| | | // template.afterPropertiesSet(); |
| | | // return template; |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // |
| | | //} |
| | | package com.ruoyi.doublePrevention.config.redis; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.connection.RedisConnectionFactory; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | | @Configuration |
| | | public class RedisConfig { |
| | | |
| | | /** |
| | | * @Description: key和value的序列化方式 |
| | | */ |
| | | @Bean |
| | | public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { |
| | | |
| | | RedisTemplate<String, Object> template = new RedisTemplate<>(); |
| | | template.setConnectionFactory(factory); |
| | | // json序列化对象 |
| | | GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer(); |
| | | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); |
| | | // key=>string |
| | | template.setKeySerializer(stringRedisSerializer); |
| | | // hash=>string |
| | | template.setHashKeySerializer(stringRedisSerializer); |
| | | // value=>json |
| | | template.setValueSerializer(jackson2JsonRedisSerializer); |
| | | // hashValue=>json |
| | | template.setHashValueSerializer(jackson2JsonRedisSerializer); |
| | | // set |
| | | template.afterPropertiesSet(); |
| | | return template; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |