无法在 Redis 中保存 java 个对象

Unable to save java object in Redis

我试图在我的机器中运行以下示例:

https://examples.javacodegeeks.com/enterprise-java/spring/spring-data-redis-example/

public static void main(String[] args) {

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new ClassPathResource("/spring/spring-config.xml").getPath());
RedisRepo redisRepo = (RedisRepo)context.getBean(“redisRepo");

        try{

            JedisPool pool = new JedisPool(new JedisPoolConfig(), "x.x.x.x”);
            Jedis jedis = pool.getResource();

            System.out.println("Connected to Redis”);//connected to Redis
            System.out.println("server is running: "+jedis.ping());//PONG
            System.out.println("current keys are :"+jedis.keys(“*”));//[ ]

            Employee s = new Employee();
            s.setId(1);
            s.setName(“abc”);
            redisRepo.saveState(s);
            System.out.println("server is running: "+jedis.ping());//PONG
            System.out.println("Finding the One : "+redisRepo.getState(1);//Finding the one :null

            }
        catch(Exception e){
            logger.error(e.getMessage(), e);
        }
}

但是在尝试保存模型对象时出现以下错误:

Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

我想补充一点,我可以通过 pinging.How 测试与 Redis 服务器的连接 我可以解决这个问题以在 Redis 中持久保存数据吗?

我可以通过 运行 redis locally.While 解决在本地实例上保存数据的问题,以便在远程服务器上保存数据我在主 class.Like 中导入了资源:

@ImportResource({classpath:path-to-youXML})