I am trying to store an object in redis and I am getting this error. reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: Cannot serialize value of type class java.lang.Integer without a serializerI have included serializers for both value and hashvalue but it doesnt work. below is my code
config
public ReactiveRedisOperations<String, Player> playerRedisOperations(LettuceConnectionFactory connectionFactory) { RedisSerializationContext<String, Player> serializationContext = RedisSerializationContext .<String, Player>newSerializationContext(new StringRedisSerializer()) .key(new StringRedisSerializer()) .value(new GenericToStringSerializer<>(Player.class)) .hashKey(new StringRedisSerializer()) .hashValue(new GenericJackson2JsonRedisSerializer()) .build(); return new ReactiveRedisTemplate<>(connectionFactory, serializationContext); }
redis repository
private final ReactiveRedisOperations<String, Player> redisOperations; private final ReactiveHashOperations<String, Integer, Player> hashOperations; public PlayerRedisRepositoryImpl(@Qualifier("playerRedisOperations")ReactiveRedisOperations<String, Player> redisOperations) { this.redisOperations = redisOperations; this.hashOperations = redisOperations.opsForHash(); } public Mono<Player> savePlayer(String key,Player player) { return hashOperations.put(key, player.user_id(), player).map(isSaved -> player); }
stacktrace
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: Cannot serialize value of type class java.lang.Integer without a serializerCaused by: java.lang.IllegalStateException: Cannot serialize value of type class java.lang.Integer without a serializer at org.springframework.data.redis.serializer.DefaultRedisElementWriter.write(DefaultRedisElementWriter.java:56) at org.springframework.data.redis.serializer.RedisSerializationContext$SerializationPair.write(RedisSerializationContext.java:287) at org.springframework.data.redis.core.DefaultReactiveHashOperations.rawHashKey(DefaultReactiveHashOperations.java:339) at org.springframework.data.redis.core.DefaultReactiveHashOperations.lambda$put$20(DefaultReactiveHashOperations.java:251) at org.springframework.data.redis.core.DefaultReactiveHashOperations.lambda$createMono$27(DefaultReactiveHashOperations.java:324) at org.springframework.data.redis.core.ReactiveRedisTemplate.lambda$doInConnection$1(ReactiveRedisTemplate.java:244) at reactor.core.publisher.FluxUsingWhen.deriveFluxFromResource(FluxUsingWhen.java:119)
what could be the issue?