mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
fix(RedissonConfig.java): redis未设置密码且配置中有password属性报错
This commit is contained in:
parent
7bd6c9ad3e
commit
f31c6a097c
@ -11,7 +11,7 @@
|
||||
|
||||
#### 项目简介
|
||||
|
||||
[youlai-mall](https://gitee.com/youlaitech/youlai-mall) 是基于Spring Boot 2.5.0、Spring Cloud 2020 & Alibaba 2021、vue、element-ui、uni-app快速构建的一套全栈开源商城项目。
|
||||
[youlai-mall](https://gitee.com/youlaitech/youlai-mall) 是基于Spring Boot 2.5、Spring Cloud 2020 & Alibaba 2021、vue、element-ui、uni-app快速构建的一套全栈开源商城项目。
|
||||
|
||||
项目采用微服务、前后端分离开发模式;汇集全栈主流的技术栈; 涉及 [后端微服务](https://gitee.com/youlaitech/youlai-mall) 、 [前端管理](https://gitee.com/youlaitech/youlai-mall-admin) 、 [微信小程序](https://gitee.com/youlaitech/youlai-mall-weapp) 和 [APP应用](https://gitee.com/youlaitech/youlai-mall-weapp) 等多端的开发。
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.youlai.common.redis.redisson;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
import org.redisson.config.SingleServerConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -21,11 +23,13 @@ public class RedissonConfig {
|
||||
return null;
|
||||
}
|
||||
Config config = new Config();
|
||||
config.useSingleServer()
|
||||
//可以用"rediss://"来启用SSL连接
|
||||
.setAddress(properties.getServerAddress() + ":" + properties.getPort())
|
||||
.setDatabase(properties.getDatabase())
|
||||
.setPassword(properties.getPassword());
|
||||
SingleServerConfig singleServerConfig = config.useSingleServer();
|
||||
singleServerConfig.setAddress(properties.getServerAddress() + ":" + properties.getPort());
|
||||
singleServerConfig.setDatabase(properties.getDatabase());
|
||||
String password = properties.getPassword();
|
||||
if (StrUtil.isNotBlank(password)) {
|
||||
singleServerConfig.setPassword(password);
|
||||
}
|
||||
return Redisson.create(config);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user