在将Redis(“使用Redisson”)与Spring Boot连接时,我遇到一些问题。应用时,开始时间显示以下错误。
“ org.springframework.beans.factory.BeanCreationException:在类路径资源[com / redisson / config / RedisConfig.class]中创建名称为'redisson'的bean时出错:通过工厂方法实例化的bean失败;嵌套异常是org.springframework。 beans.BeanInstantiationException:无法实例化[org.redisson.api.RedissonClient]:工厂方法'redisson'抛出异常;嵌套的异常是java.lang.IllegalArgumentException:方案名称中索引0的非法字符:127.0.0.1:6379“
我的代码仅在春季@Bean中进行连接
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);
> }
>
> }
java.net.URI例外。如果您使用的是非法地址格式,请尝试将其更改为"redis://127.0.0.1:6379"
。我猜应该可以解决您的问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句