springcloud使用redisson-spring-boot-starter从nacos配置中心获取redis配置

宗冠宇
2023-12-01

1、pom文件添加

        <dependency>
            <groupId>org.redisson</groupId>
            <artifactId>redisson-spring-boot-starter</artifactId>
            <version>3.15.1</version>
        </dependency>

2、nacos中redis配置文件

spring:
  redis:
    redisson:
      config: |
        singleServerConfig:
          idleConnectionTimeout: 10000
          connectTimeout: 10000
          timeout: 3000
          retryAttempts: 3
          retryInterval: 1500
          address: redis://192.168.5.174:6379
          password: ld123456
          clientName: null
          keepAlive: false
          tcpNoDelay: false
        threads: 16
        nettyThreads: 32
        codec: !<org.redisson.codec.JsonJacksonCodec> {}
        transportMode: "NIO"

3、整合RedisTemplate

 

package com.pojo.common.
 类似资料: