set注入失败 构造器注入成功
@Component
@Slf4j
public class UserCookieInfoUtil {
private static RedisTemplate<String, String> redisTemplate;
private static JWTUtils jwtUtils;
@Autowired
public UserCookieInfoUtil(JWTUtils jwtUtils, RedisTemplate<String, String> redisTemplate) {
UserCookieInfoUtil.jwtUtils = jwtUtils;
UserCookieInfoUtil.redisTemplate = redisTemplate;
}
public static Map<String, Object> getCookieInfo(String token) {
Map<String, Object> map = new HashMap<>();
try {
String loginName = jwtUtils.getLoginName(token);
String info = redisTemplate.opsForValue().get(Constants.TOKEN_USER_INFO + ":" + loginName);
map = JSONObject.parseObject(info == null ? "" : info, Map.class);
} catch (Exception e){
log.error("获取缓存中的登录信息失败:{}", e);
}
return map;
}
}