【发布时间】:2021-03-20 12:13:35
【问题描述】:
当我重新启动 redis 原因
java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: NOAUTH 需要身份验证。
为什么这是个问题
使用这样的版本
@Configuration
public class RedisConfig {
@Autowired
private RedisProperties redisProperties;
@Bean(destroyMethod = "close")
public StatefulRedisConnection<String, Object> StatefulRedisConnection() {
RedisURI redisUri = RedisURI.builder().withPassword(redisProperties.getPassword())
.withSentinel(redisProperties.getSentinel().getNodes().get(0).split(":")[0],
Integer.valueOf(redisProperties.getSentinel().getNodes().get(0).split(":")[1]))
.withSentinelMasterId(redisProperties.getSentinel().getMaster())
.withDatabase(redisProperties.getDatabase()).build();
RedisClient redisClient = RedisClient.create(redisUri);
return redisClient.connect(new SerializedObjectCodec());
}
}
public class CacheImpl implements Cache {
@Autowired
private StatefulRedisConnection connect;
public Boolean addCourseInfosCache() {
RedisAsyncCommands<String, Object> commands = connect.async();
// disable auto-flushing
commands.setAutoFlushCommands(false);
List<RedisFuture<?>> futures = Lists.newArrayList();
commands.flushCommands();
}
}
【问题讨论】:
标签: java spring-boot redis spring-data-redis lettuce