zoukankan      html  css  js  c++  java
  • 12月6号 解决redis乱码问题

    import lombok.extern.slf4j.Slf4j;
    import org.springframework.beans.factory.annotation.Autowired;
    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.*;
    import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
    import org.springframework.data.redis.serializer.StringRedisSerializer;
    import org.springframework.data.redis.serializer.RedisSerializer;
    
    @Configuration
    @Slf4j
    public class RedisConfig {
        @Autowired
        private RedisConnectionFactory factory;
    
        @SuppressWarnings({ "rawtypes", "unused" })
        private RedisTemplate redisTemplate;
    
        @SuppressWarnings({ "rawtypes", "unchecked" })
        @Autowired(required = false)
        public void setRedisTemplate(RedisTemplate redisTemplate) {
            RedisSerializer stringSerializer = new StringRedisSerializer();
            redisTemplate.setKeySerializer(stringSerializer);
            redisTemplate.setValueSerializer(stringSerializer);
            redisTemplate.setHashKeySerializer(stringSerializer);
            redisTemplate.setHashValueSerializer(stringSerializer);
            this.redisTemplate = redisTemplate;
        }

    这样配置后 redis ok

  • 相关阅读:
    在python3.x上安装suds 并访问webservice
    numpy nonzero与isnan
    彻底弄清python的切片
    pandas read_sql与read_sql_table、read_sql_query 的区别
    dataframe to sql
    同时替换掉多个字符串
    matplotlib中在for中画出多张图
    MySql 创建/删除数据库
    python3与anaconda2共存
    js调用打印机
  • 原文地址:https://www.cnblogs.com/lyon91/p/10077601.html
Copyright © 2011-2022 走看看