SpringBoot integrates Redis

SpringBoot integrates Redis

maven project advantages

Maintain and manage third-party jar packages. There is a dependency relationship between the actual application projects. If project A depends on the CD project, we may know the jar package required by project A, but the CD project may not be clear. Maven can help solve this problem. After completing the configuration, the Maven project can automatically import directly or indirectly dependent jar packages.

guide package

maven project, jar package dependencies are

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

write yml file

##redis配置信息
spring:
  redis:
    database: 0 #redis数据库索引,默认为0
    host: 127.0.0.1 #redis服务器地址
    port: 6379 #redis服务器连接端口
    password: #redis服务器连接密码,默认为null
    timeout: 5000 #redis连接超时时间
# ******** 如果不使用连接池,那么下面这部分可省略不写 ********
    jedis:
      pool: #连接池配置
        max-active: 8 #连接池最大连接数
        max-wait: -1 #连接池最大阻塞等待时间
        max-idle: 8 #连接池中的最大空闲连接数
        min-idle: 0 #连接池中的最小空闲连接数
        ```

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324101565&siteId=291194637