//一个对象要存储到redis里面可能发生存的是对象,取出来之后无法还原的问题
下面我演示一下;
//存储对象
Test t=new Test();
//存储到redis时,我们转换为json字符串进行存储;
String jsonString=JSON.toJSONString()
//然后进行存储
redisCache.setCacheObject("test",jsonString);
//还原成对象处理
Test t1=redisCache.parseObject(cacheObject, Tset.class);
下面是我的代码:
@Service
public class LoginServerImp implements LoginServer {
@Autowired
private RedisCache redisCache;
@Autowired
private AuthenticationManager authenticationManager;
@Override
public ResponseResult login(User user) {
UsernamePasswordAuthenticationToken authenticationToken=
new UsernamePasswordAuthenticationToken(user.getId(),user.getPassword());
Authentication authenticate = authenticationManager.authenticate(authentica