Skip to content

Commit

Permalink
redis 密码空时,异常
Browse files Browse the repository at this point in the history
  • Loading branch information
千面 committed Dec 17, 2021
1 parent 6a8bb4a commit 01edf29
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

@Data
@Configuration
Expand Down Expand Up @@ -38,6 +39,7 @@ public class RedissonConfig {
@Bean(destroyMethod = "shutdown")
public RedissonClient redisson() throws Exception {
Config config = new Config();
String password = redisProperties.getPassword();
config.useSingleServer().setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort())
.setConnectionMinimumIdleSize(connectionMinimumIdleSize)
.setConnectionPoolSize(connectionPoolSize)
Expand All @@ -52,7 +54,7 @@ public RedissonClient redisson() throws Exception {
.setTimeout(timeout)
.setConnectTimeout(connectTimeout)
.setIdleConnectionTimeout(idleConnectionTimeout)
.setPassword(redisProperties.getPassword());
.setPassword(StringUtils.isEmpty(password) ? null : password);
config.setThreads(thread);
config.setEventLoopGroup(new NioEventLoopGroup());
return Redisson.create(config);
Expand Down

0 comments on commit 01edf29

Please sign in to comment.