“Spring Boot 连 Redis Cluster”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
(建立内容为“1”的新页面)
 
第1行: 第1行:
1
+
=== pom.xml ===
 +
<syntaxhighlight lang="xml">
 +
    <parent>
 +
        <groupId>org.springframework.boot</groupId>
 +
        <artifactId>spring-boot-starter-parent</artifactId>
 +
        <version>2.4.13</version>
 +
    </parent>
 +
 
 +
    <properties>
 +
        <maven.compiler.source>8</maven.compiler.source>
 +
        <maven.compiler.target>8</maven.compiler.target>
 +
    </properties>
 +
 
 +
    <dependencies>
 +
        <dependency>
 +
            <groupId>org.springframework.boot</groupId>
 +
            <artifactId>spring-boot-starter-test</artifactId>
 +
            <scope>test</scope>
 +
        </dependency>
 +
 
 +
        <dependency>
 +
            <groupId>org.projectlombok</groupId>
 +
            <artifactId>lombok</artifactId>
 +
        </dependency>
 +
 
 +
        <dependency>
 +
            <groupId>org.springframework.boot</groupId>
 +
            <artifactId>spring-boot-starter-data-redis</artifactId>
 +
        </dependency>
 +
 
 +
 
 +
        <dependency>
 +
            <groupId>org.springframework.boot</groupId>
 +
            <artifactId>spring-boot-starter-web</artifactId>
 +
        </dependency>
 +
 
 +
        <dependency>
 +
            <groupId>org.springframework.boot</groupId>
 +
            <artifactId>spring-boot-configuration-processor</artifactId>
 +
            <optional>true</optional>
 +
        </dependency>
 +
 
 +
    </dependencies>
 +
</syntaxhighlight>
 +
 
 +
 
 +
 
 +
=== application.yml ===
 +
<syntaxhighlight lang="yaml">
 +
spring:
 +
  redis:
 +
    password: vn4sj5kbxdaG
 +
    cluster:
 +
      nodes:
 +
        - 127.0.0.1:6379
 +
        - 127.0.0.1:6380
 +
        - 127.0.0.1:6381
 +
        - 127.0.0.1:6479
 +
        - 127.0.0.1:6480
 +
        - 127.0.0.1:6481
 +
      max-redirects: 3
 +
</syntaxhighlight>访问集群其实也只需要一个密码
 +
 
 +
max-redirects

2023年2月20日 (一) 04:52的版本

pom.xml

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.13</version>
    </parent>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

    </dependencies>


application.yml

spring:
  redis:
    password: vn4sj5kbxdaG
    cluster:
      nodes:
        - 127.0.0.1:6379
        - 127.0.0.1:6380
        - 127.0.0.1:6381
        - 127.0.0.1:6479
        - 127.0.0.1:6480
        - 127.0.0.1:6481
      max-redirects: 3

访问集群其实也只需要一个密码

max-redirects