Skip to content

Commit

Permalink
fix:修复本地环境下Redis密码为空启动报错
Browse files Browse the repository at this point in the history
  • Loading branch information
qirui33 committed Mar 4, 2024
1 parent f256332 commit a46f3cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.abin.mallchat.common.common.config;

import cn.hutool.core.util.StrUtil;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -23,8 +25,13 @@ public RedissonClient redissonClient() {
Config config = new Config();
config.useSingleServer()
.setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort())
.setPassword(redisProperties.getPassword())
.setDatabase(redisProperties.getDatabase());
System.err.println(redisProperties.getPassword());
System.out.println(!"''".equals(redisProperties.getPassword()));
if (StrUtil.isNotEmpty(redisProperties.getPassword()) && !"''".equals(redisProperties.getPassword())) {
config.useSingleServer().setPassword(redisProperties.getPassword());
}
return Redisson.create(config);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mallchat.mysql.password=123456
##################redis??##################
mallchat.redis.host=127.0.0.1
mallchat.redis.port=6379
mallchat.redis.password=123456
mallchat.redis.password=''
##################jwt##################
mallchat.jwt.secret=dsfsdfsdfsdfsd
##################???????##################
Expand Down

0 comments on commit a46f3cb

Please sign in to comment.