1、//数据存入redis中
redisTemplate.opsForValue().set(loginame, JSON.toJSONString(users),1000,TimeUnit.SECONDS);
2、//获取数据并转成用户实体
String userJson = (String) redisTemplate.opsForValue().get("loginame");
UserEntity user = (UserEntity) JSONArray.parseArray(userJson, UserEntity.class);
原文:https://www.cnblogs.com/yebuzhiqiu/p/13608965.html