@Service class SomeService{ private HashOperations<String, String, Integer> intHashOps;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@PostConstruct
void init(){
hashOps = redisTemplate.opsForHash();
}
void do(){
intHashOps.put("loginFailCount", username, 1); //抛出异常
}
}
上面的代码中,调用 do()抛出异常 java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String 这是怎么回事啊?