SpringBoot集成redis配置文件不生效踩坑记录

  • SpringBoot版本
      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>3.1.2</version>
    </parent>
    
  • 导入spring-boot-stater-data-redis依赖
       <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
      </dependency>
    
  • 不生效的配置
      spring:
        redis:
          host: 192.168.40.133
          port: 6379
    
    报错
      Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379
    
    连接的是localhost,说明配置文件没有生效
  • 修改后的正确配置
      spring:
        data:
          redis:
            host: 192.168.40.133
            port: 6379
    

问题解决!

posted @ 2024-06-23 23:26  ydw333  阅读(675)  评论(0)    收藏  举报