I am facing some issue while connecting Redis("Using Redisson") with spring boot. At aplication Start time show below error.
"org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisson' defined in class path resource [com/redisson/config/RedisConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'redisson' threw exception; nested exception is java.lang.IllegalArgumentException: Illegal character in scheme name at index 0: 127.0.0.1:6379"
MY code is only doing connection in spring @Bean only
package com.redisson.config;
>
> import java.io.IOException;
>
> import org.redisson.Redisson; import org.redisson.api.RedissonClient;
> import org.redisson.config.Config; import
> org.springframework.beans.factory.annotation.Value; import
> org.springframework.context.annotation.Bean; import
> org.springframework.context.annotation.ComponentScan; import
> org.springframework.context.annotation.Configuration;
>
> @Configuration @ComponentScan({"com.redisson.config"}) public class
> RedisConfig {
>
> @Value("${spring.redis.url}") String REDIS_URL;
> @Bean(destroyMethod="shutdown")
> RedissonClient redisson() throws IOException { System.out.println("Redis url"+REDIS_URL);
> Config config = new Config();
> //config.useClusterServers().addNodeAddress("127.0.0.1:6379");
> config.useSingleServer().setAddress("127.0.0.1:6379");
> return Redisson.create(config);
> }
>
> }
It's an exception from java.net.URI
. It occurs because you use an illegally formatted address. Try to change it to "redis://127.0.0.1:6379"
. It should resolve your problem.