学无先后,达者为师

网站首页 编程语言 正文

SpringBoot 2.X 整合Redis

作者:杜小舟 更新时间: 2022-08-05 编程语言

SpringBoot 2.X 整合Redis

SpringBoot Maven依赖以及版本

<properties>
	<spring.boot.version>2.4.2</spring.boot.version>
</properties>
<dependencyManagement>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>${spring.boot.version}</version>
		<type>pom</type>
		<scope>import</scope>
	</dependency>
</dependencyManagement>

Redis Maven依赖以及版本

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

Redis 在yml配置文件中的配置

我使用的是Jedis连接方式

spring:
  redis:
    jedis:
      pool:
        max-wait: 1000ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
        max-active: 600 # 连接池最大连接数
        max-idle: 300 # 连接池中的最大空闲连接
        min-idle: 0 # 连接池中的最小空闲连接
    host: 127.0.0.1
    port: 6379
    password:

RedisConfig配置文件

RedisConfig配置文件 请看这里


RedisUtils文件

RedisUtils工具类 请看这里





End


原文链接:https://blog.csdn.net/weixin_43657300/article/details/126051333

栏目分类
最近更新