8、Redis整合SpringBoot

1、依赖导入

<!-- redis -->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-data-redis</artifactId>

</dependency>

<!-- spring2.X集成redis所需common-pool2-->

<dependency>

<groupId>org.apache.commons</groupId>

<artifactId>commons-pool2</artifactId>

<version>2.6.0</version>

</dependency>

2、application.yml文件配置

spring:

redis:

#Redis服务器地址

host: 175.178.27.250

#Redis密码

password: root123

#Redis服务器连接端口

port: 6379

#Redis数据库索引(默认为0)

database: 0

#连接超时时间(毫秒)

timeout: 1800000

#连接池配置

lettuce:

pool:

#连接池最大连接数(使用负值表示没有限制)

max-active: 20

#最大阻塞等待时间(负数表示没限制)

max-wait: -1

#连接池中的最大空闲连接

max-idle: 5

#连接池中的最小空闲连接

min-idle: 0

posted @ 2022-11-11 22:58  枫叶红时  阅读(37)  评论(0)    收藏  举报