springboot 启动报错,连接不上redis集群

chenyu8104 2021-09-19 12:07:44

我的配置

dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.lettuce</groupId>
                    <artifactId>lettuce-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
<!--            <version>2.9.0</version>-->
        </dependency>
pring:
  redis:
#    host: 127.0.0.1
#    port: 7001
    cluster:
      nodes:
        - 127.0.0.1: 7001
        - 127.0.0.1: 7002
        - 127.0.0.1: 7003
        - 127.0.0.1: 8001
        - 127.0.0.1: 8002
        - 127.0.0.1: 8003

出现下面错误

09-19 12:00:04:406  WARN 37108 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stringRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'stringRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.redis.JedisConnectionConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties': Could not bind properties to 'RedisProperties' : prefix=spring.redis, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.redis.cluster.nodes' to java.util.List<java.lang.String>
09-19 12:00:04:408  INFO 37108 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
09-19 12:00:04:414  INFO 37108 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
09-19 12:00:04:419 ERROR 37108 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@1bd81830 type = java.util.List<java.lang.String>, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: spring.redis.cluster.nodes[0].127.0.0.1
    Value: 7001
    Origin: class path resource [application.yaml]:12:22
    Reason: The elements [spring.redis.cluster.nodes[0].127.0.0.1,spring.redis.cluster.nodes[1].127.0.0.1,spring.redis.cluster.nodes[2].127.0.0.1,spring.redis.cluster.nodes[3].127.0.0.1,spring.redis.cluster.nodes[4].127.0.0.1,spring.redis.cluster.nodes[5].127.0.0.1] were left unbound.
    Property: spring.redis.cluster.nodes[1].127.0.0.1
    Value: 7002
    Origin: class path resource [application.yaml]:13:22
    Reason: The elements [spring.redis.cluster.nodes[0].127.0.0.1,spring.redis.cluster.nodes[1].127.0.0.1,spring.redis.cluster.nodes[2].127.0.0.1,spring.redis.cluster.nodes[3].127.0.0.1,spring.redis.cluster.nodes[4].127.0.0.1,spring.redis.cluster.nodes[5].127.0.0.1] were left unbound.
    Property: spring.redis.cluster.nodes[2].127.0.0.1
    Value: 7003
    Origin: class path resource [application.yaml]:14:22
    Reason: The elements [spring.redis.cluster.nodes[0].127.0.0.1,spring.redis.cluster.nodes[1].127.0.0.1,spring.redis.cluster.nodes[2].127.0.0.1,spring.redis.cluster.nodes[3].127.0.0.1,spring.redis.cluster.nodes[4].127.0.0.1,spring.redis.cluster.nodes[5].127.0.0.1] were left unbound.
    Property: spring.redis.cluster.nodes[3].127.0.0.1
    Value: 8001
    Origin: class path resource [application.yaml]:15:22
    Reason: The elements [spring.redis.cluster.nodes[0].127.0.0.1,spring.redis.cluster.nodes[1].127.0.0.1,spring.redis.cluster.nodes[2].127.0.0.1,spring.redis.cluster.nodes[3].127.0.0.1,spring.redis.cluster.nodes[4].127.0.0.1,spring.redis.cluster.nodes[5].127.0.0.1] were left unbound.
    Property: spring.redis.cluster.nodes[4].127.0.0.1
    Value: 8002
    Origin: class path resource [application.yaml]:16:22
    Reason: The elements [spring.redis.cluster.nodes[0].127.0.0.1,spring.redis.cluster.nodes[1].127.0.0.1,spring.redis.cluster.nodes[2].127.0.0.1,spring.redis.cluster.nodes[3].127.0.0.1,spring.redis.cluster.nodes[4].127.0.0.1,spring.redis.cluster.nodes[5].127.0.0.1] were left unbound.
    Property: spring.redis.cluster.nodes[5].127.0.0.1
    Value: 8003
    Origin: class path resource [application.yaml]:17:22
    Reason: The elements [spring.redis.cluster.nodes[0].127.0.0.1,spring.redis.cluster.nodes[1].127.0.0.1,spring.redis.cluster.nodes[2].127.0.0.1,spring.redis.cluster.nodes[3].127.0.0.1,spring.redis.cluster.nodes[4].127.0.0.1,spring.redis.cluster.nodes[5].127.0.0.1] were left unbound.

Action:

Update your application's configuration
 

通过配置 host 和port 连接单个redis服务是可以连接上的

求助各位大神

...全文
1903 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
=PNZ=BeijingL 2021-09-23
  • 打赏
  • 举报
回复

BindException: Failed to bind properties under 'spring.redis.cluster.nodes' to java.util.List<java.lang.String>

nodes节点配置不对,这么写试试192.168.32.100:7001 ,192.168.32.101:7001

51,399

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧