出现这个问题可排查下redis对应的key值是否在缓存中已经存在,且与格式要求不符。
@Autowired private RedisProperties redisProperties; private final int SINGLE_IP_NODE = 8; @Value("${spring.redis.mode:cluster}") String redisMode; @Bean public RedissonClient redissonClient() { if("cluster".equals(redisMode)){ Config config = new Config(); String ip = redisProperties.getHost(); String[] ipList = ip.split(";");
RedissonClient redissonClient = AppContext.getBean(RedissonClient.class); RLock lock = redissonClient.getLock(key); lock.lock(90000L, TimeUnit.MILLISECONDS); try { RBucket<Map<String, Object>> bucket = redissonClient.getBucket(SNOW_FLAKED_ID + "_KEY"); Map<String, Object> map = bucket.get(); int workId = 0;}
用redisson生成雪花id,项目启动的时候一直报错,排查很久配置都没问题,才想起之前由于配置redis有问题,已经生成过错误格式的key(SNOW_FLAKED_ID + "_KEY")对应的bucket,修改redis的key后项目正常启动。
org.redisson.client.RedisException: Unexpected exception while processing command at com.abi.claimbook.controller.AuthController.checkLoginCredentials(AuthController.java:97) at com.abi.claimbook.controller.AuthController$$FastClassBySpringCGLIB$$f6e9fa9a.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) .... ....