From f31c6a097c931e565d11f0265e468410887c75a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E6=9D=A5=E6=8A=80=E6=9C=AF?= <1490493387@qq.com> Date: Sat, 14 Aug 2021 01:36:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(RedissonConfig.java):=20redis=E6=9C=AA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=AF=86=E7=A0=81=E4=B8=94=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E6=9C=89password=E5=B1=9E=E6=80=A7=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../common/redis/redisson/RedissonConfig.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7bc3c9ba3..163b2707e 100644 --- a/README.md +++ b/README.md @@ -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) 等多端的开发。 diff --git a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/redisson/RedissonConfig.java b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/redisson/RedissonConfig.java index 7b17ea4db..13bf1d763 100644 --- a/youlai-common/common-redis/src/main/java/com/youlai/common/redis/redisson/RedissonConfig.java +++ b/youlai-common/common-redis/src/main/java/com/youlai/common/redis/redisson/RedissonConfig.java @@ -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); }