Tag Archives: Caused by: java.lang.IllegalArgumentException: RIVER

[Solved] Redisson Error: Caused by: java.lang.IllegalArgumentException: RIVER

Spring integrates redisson and reports an error when starting the project: caused by: java.lang.illegalargumentexception: River

package com.user.base.utils.redis.redisson;

import java.io.IOException;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * get redisson
 * @author Administrator
 *
 */
@Configuration
public class RedissonConfig {
    /*
     * SecondKillServiceImp.java
     */
    @Bean/*(destroyMethod = "shutdown")*/
    RedissonClient redisson(){ // throws IOException 
        Config config = new Config();
        //config.useClusterServers().addNodeAddress("127.0.0.1:6379");
        config.useSingleServer().setAddress("redis://127.0.0.1:64791");
        //config.useClusterServers().addNodeAddress("redis://127.0.0.1:6379","redis://127.0.0.1:6380");
        config.setCodec(new org.redisson.client.codec.StringCodec());
        RedissonClient redissonClient = null;
        try{
            redissonClient = Redisson.create(config);
        }catch(Exception e){
            e.printStackTrace();
        }
        return redissonClient;
    }
}

Solution: add

config.setCodec(new org.redisson.client.codec.StringCodec());

After adding this sentence, the exception is excluded.

//Specify the code. The default code is org.redisson.codec.jsonjacksoncode
// the previous spring data redis and the client jedis are encoded as org.springframework.data.redis.serializer.stringredisserializer
// after redisson is used, in order to ensure data compatibility between them, the code is modified to org.redisson.client.codec.stringcodec