Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring启动应用程序未启动,Redis Sentinel属性错误无效_Java_Spring Boot_Redis_Lettuce_Redis Sentinel - Fatal编程技术网

Java Spring启动应用程序未启动,Redis Sentinel属性错误无效

Java Spring启动应用程序未启动,Redis Sentinel属性错误无效,java,spring-boot,redis,lettuce,redis-sentinel,Java,Spring Boot,Redis,Lettuce,Redis Sentinel,我正在尝试在本地系统中使用Redis Sentinel启动我的应用程序 当我启动应用程序时,它会因以下错误而停止。我已经在我的windows机器上启动了redis,主机在6379端口,副本在6380和6381端口,哨兵在263792638026381端口。我可以使用redis cli命令连接到redis服务器 上下文初始化过程中遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建名为\u0027redisCo

我正在尝试在本地系统中使用Redis Sentinel启动我的应用程序

当我启动应用程序时,它会因以下错误而停止。我已经在我的windows机器上启动了redis,主机在6379端口,副本在6380和6381端口,哨兵在263792638026381端口。我可以使用redis cli命令连接到redis服务器

上下文初始化过程中遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建名为\u0027redisConnectionFactory\u0027的bean时出错,该bean在类路径资源[org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]中定义:通过工厂方法实例化Bean失败;嵌套异常为org.springframework.beans.beans实例化异常:未能实例化[org.springframework.data.redis.connection.莴苣.LettuceConnectionFactory]:工厂方法\u0027redisConnectionFactory\u0027抛出异常;嵌套异常为java.lang.IllegalStateException:无效的redis sentinel属性\u0027127.0.0.1\u0027“

下面是我的redis配置类

@Configuration
public class RedisConfigurations {

    private final RedisProperties redisProperties;

    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.redis.port}")
    private Integer redisPort;

    @Value("${spring.redis.database}")
    private Integer database;

    @Value("${spring.redis.password}")
    private String redisPwd;


    @Bean
    protected LettuceConnectionFactory redisConnectionFactory() {
        RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration()
                .master(redisProperties.getSentinel().getMaster());
        redisProperties.getSentinel().getNodes().forEach(s -> sentinelConfig.sentinel(s, redisProperties.getPort()));
        sentinelConfig.setPassword(RedisPassword.of(redisProperties.getPassword()));
        sentinelConfig.setDatabase(database);
        return new LettuceConnectionFactory(sentinelConfig, LettuceClientConfiguration.defaultConfiguration());
    }

    public <T> Jackson2JsonRedisSerializer<T> configureJackson2JsonRedisSerializer(Class<T> t) {
        Jackson2JsonRedisSerializer<T> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(t);
        jackson2JsonRedisSerializer.setObjectMapper(new ObjectMapper());
        return jackson2JsonRedisSerializer;
    }

    @Bean
    public RedisTemplate<String, Object> redisTemplate() {
        final RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashKeySerializer(new GenericToStringSerializer<>(Object.class));
        redisTemplate.setValueSerializer(configureJackson2JsonRedisSerializer(Object.class));
        redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
        redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
        redisTemplate.setConnectionFactory(redisConnectionFactory());
        return redisTemplate;
    }
spring:
  application:
    name: some-app
  profiles:
    active: local
  main:
    allow-bean-definition-overriding: true
  redis:
    host: 127.0.0.1
    port: 26380
    database: 0
    sentinel:
      master: master
      nodes:
        - 127.0.0.1
        - 127.0.0.1
        - 127.0.0.1
    lettuce:
      shutdown-timeout: 100ms
      pool:
        max-active: 5
        min-idle: 2
        max-wait: 1ms