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
Similar Posts:
- Springboot Failed to parse configuration class [x]
- The prefix “mvc” for element “mvc:annotation-driven” is not bound Error
- Springboot starts with @ scheduled and reports an error: no qualifying bean
- Two ways to implement Spring Boot’s scanmapper interface class
- Spring cloud consumer feign injection error [How to Solve]
- [Solved] Jedis:Exception in thread “main” java.lang.VerifyError: Bad type on operand stack
- [Solved] Spring Boot Error: The field file exceeds its maximum permitted size of 1048576 bytes
- [Solved] Springboot Use Redis Error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘redisTemplate’ defined in class path resource
- [Solved] redisson Error: IllegalArgumentException: port out of range:-1
- [Solved] Dependency injection exception: org.springframework.beans.factory.UnsatisfiedDependencyException