SpringBoot中使用RedisTemplate报错 ERR value is not an integer or out of range

  • Post author:
  • Post category:其他

问题描述:在Spring Boot(当前版本为2.4.2)项目中引入下述redis依赖,在执行redis递增操作时,控制台报错:io.lettuce.core.RedisCommandExecutionException: ERR value is not an integer or out of range

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-redis</artifactId>
	<version>2.7.3</version>
</dependency>
redisTemplate.opsForValue().increment(key,1);

解决方法:出现上述错误,这是由于序列化的问题,我们可以新增一个如下所示的配置类

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springf

版权声明:本文为y_bccl27原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。