序列化和反序列化问题:
放在config目录下
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import javax.annotation.PostConstruct;
@Configuration
public class RedisTempleteConfig {
@Autowired
RedisTemplate redisTemplate;
@PostConstruct
private void init(){
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
}
}
后记:
后来用了公司自带的redis框架里面的函数,序列化 反序列化的问题都没有了,只需要按照他给的demo改一改,轻松实现各种查询,删除和修改。。。真是笑哭了。。。