一、基本集成套路:
- 环境依赖
修改 POM 文件,添加 spring-boot-starter-redis 依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
- 数据源
方案一 使用 Spring Boot 默认配置
在 src/main/resources/application.properties 中配置数据源信息。
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=
spring.redis.database=1
spring.redis.pool.max-active=8
spring.redis.pool.max-wait=-1
spring.redis

本文详细介绍了Spring Boot与Redis的集成,包括POM依赖、数据源配置、对象序列化、缓存管理和Session共享。通过自动配置和自定义RedisTemplate实现对象的读写,启用@EnableCaching注解进行缓存管理,并展示了使用spring-session-data-redis实现Session共享的步骤。
最低0.47元/天 解锁文章
2226

被折叠的 条评论
为什么被折叠?



