springboot集成redisson启动报错:Unable to connect to Redis server
redisson
Redisson - Easy Redis Java client with features of In-Memory Data Grid. Sync/Async/RxJava/Reactive API. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache ...
项目地址:https://gitcode.com/gh_mirrors/re/redisson
免费下载资源
·
redis未配置密码时springboot集成redisson启动报错Unable to connect to Redis server。
application.yml配置:
spring:
redis:
host: 127.0.0.1
port: 6379
password:
方式一:
maven依赖:
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.9.1</version>
</dependency>
重新实现实现RedissonClient:
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private Integer port;
@Value("${spring.redis.password}")
private String password;
@Bean
public RedissonClient redissonClient() {
Config config = new Config();
config.useSingleServer()
.setAddress("redis://" + host + ":" + port);
if (StringUtils.isNotEmpty(password)) {
config.useSingleServer().setPassword(password);
}
return Redisson.create(config);
}
}
方式二:
maven依赖:
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.8.2</version>
</dependency>
重新实现实现Redisson :
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private Integer port;
@Value("${spring.redis.password}")
private String password;
@Bean
public Redisson getClient () {
Config config = new Config();
config.useSingleServer().setAddress("redis://" + host + ":" + port);
// .setPassword(password);
if (StringUtils.isNotEmpty(password)) {
config.useSingleServer().setPassword(password);
}
return (Redisson)Redisson.create(config);
}
}
GitHub 加速计划 / re / redisson
23.06 K
5.31 K
下载
Redisson - Easy Redis Java client with features of In-Memory Data Grid. Sync/Async/RxJava/Reactive API. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache ...
最近提交(Master分支:2 个月前 )
15bd94ed - 3 个月前
d220f2a8 - 3 个月前
更多推荐
已为社区贡献2条内容
所有评论(0)