Commit 86eae989f90c240fdf2adbab05a93cec79167f6a
1 parent
c98fd955
fix(redis): 适配 Redisson 4.6 的 Spring Data Redis 依赖
- 排除 Redisson 默认引入的 redisson-spring-data-41 - 显式使用 redisson-spring-data-35 适配 Spring Boot 3.5 - RedisTemplate 复用同一个 JSON RedisSerializer - 单测基类切换为 RedissonAutoConfigurationV2
Showing
5 changed files
with
22 additions
and
7 deletions
yudao-dependencies/pom.xml
| ... | ... | @@ -260,8 +260,18 @@ |
| 260 | 260 | <groupId>org.springframework.boot</groupId> |
| 261 | 261 | <artifactId>spring-boot-starter-actuator</artifactId> |
| 262 | 262 | </exclusion> |
| 263 | + <exclusion> | |
| 264 | + <groupId>org.redisson</groupId> | |
| 265 | + <!-- Redisson 4.6.x 默认依赖 redisson-spring-data-41(适配 Spring Data Redis 4.x),排除后使用下方的 spring-data-35 适配 Spring Boot 3.5 --> | |
| 266 | + <artifactId>redisson-spring-data-41</artifactId> | |
| 267 | + </exclusion> | |
| 263 | 268 | </exclusions> |
| 264 | 269 | </dependency> |
| 270 | + <dependency> | |
| 271 | + <groupId>org.redisson</groupId> | |
| 272 | + <artifactId>redisson-spring-data-35</artifactId> | |
| 273 | + <version>${redisson.version}</version> | |
| 274 | + </dependency> | |
| 265 | 275 | |
| 266 | 276 | <dependency> |
| 267 | 277 | <groupId>com.dameng</groupId> | ... | ... |
yudao-framework/yudao-spring-boot-starter-redis/pom.xml
| ... | ... | @@ -26,6 +26,10 @@ |
| 26 | 26 | <groupId>org.redisson</groupId> |
| 27 | 27 | <artifactId>redisson-spring-boot-starter</artifactId> |
| 28 | 28 | </dependency> |
| 29 | + <dependency> | |
| 30 | + <groupId>org.redisson</groupId> | |
| 31 | + <artifactId>redisson-spring-data-35</artifactId> | |
| 32 | + </dependency> | |
| 29 | 33 | |
| 30 | 34 | <dependency> |
| 31 | 35 | <groupId>org.springframework.boot</groupId> | ... | ... |
yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoRedisAutoConfiguration.java
| ... | ... | @@ -28,9 +28,10 @@ public class YudaoRedisAutoConfiguration { |
| 28 | 28 | // 使用 String 序列化方式,序列化 KEY 。 |
| 29 | 29 | template.setKeySerializer(RedisSerializer.string()); |
| 30 | 30 | template.setHashKeySerializer(RedisSerializer.string()); |
| 31 | - // 使用 JSON 序列化方式(库是 Jackson ),序列化 VALUE 。 | |
| 32 | - template.setValueSerializer(buildRedisSerializer()); | |
| 33 | - template.setHashValueSerializer(buildRedisSerializer()); | |
| 31 | + // 使用 JSON 序列化方式,序列化 VALUE | |
| 32 | + RedisSerializer<?> redisSerializer = buildRedisSerializer(); | |
| 33 | + template.setValueSerializer(redisSerializer); | |
| 34 | + template.setHashValueSerializer(redisSerializer); | |
| 34 | 35 | return template; |
| 35 | 36 | } |
| 36 | 37 | ... | ... |
yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java
| ... | ... | @@ -8,7 +8,7 @@ import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; |
| 8 | 8 | import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration; |
| 9 | 9 | import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure; |
| 10 | 10 | import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; |
| 11 | -import org.redisson.spring.starter.RedissonAutoConfiguration; | |
| 11 | +import org.redisson.spring.starter.RedissonAutoConfigurationV2; | |
| 12 | 12 | import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; |
| 13 | 13 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| 14 | 14 | import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; |
| ... | ... | @@ -44,7 +44,7 @@ public class BaseDbAndRedisUnitTest { |
| 44 | 44 | RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer |
| 45 | 45 | YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 |
| 46 | 46 | RedisAutoConfiguration.class, // Spring Redis 自动配置类 |
| 47 | - RedissonAutoConfiguration.class, // Redisson 自动配置类 | |
| 47 | + RedissonAutoConfigurationV2.class, // Redisson 自动配置类 | |
| 48 | 48 | |
| 49 | 49 | // 其它配置类 |
| 50 | 50 | SpringUtil.class | ... | ... |
yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseRedisUnitTest.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.framework.test.core.ut; |
| 3 | 3 | import cn.hutool.extra.spring.SpringUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; |
| 5 | 5 | import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration; |
| 6 | -import org.redisson.spring.starter.RedissonAutoConfiguration; | |
| 6 | +import org.redisson.spring.starter.RedissonAutoConfigurationV2; | |
| 7 | 7 | import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; |
| 8 | 8 | import org.springframework.boot.test.context.SpringBootTest; |
| 9 | 9 | import org.springframework.context.annotation.Import; |
| ... | ... | @@ -25,7 +25,7 @@ public class BaseRedisUnitTest { |
| 25 | 25 | RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer |
| 26 | 26 | RedisAutoConfiguration.class, // Spring Redis 自动配置类 |
| 27 | 27 | YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 |
| 28 | - RedissonAutoConfiguration.class, // Redisson 自动配置类 | |
| 28 | + RedissonAutoConfigurationV2.class, // Redisson 自动配置类 | |
| 29 | 29 | |
| 30 | 30 | // 其它配置类 |
| 31 | 31 | SpringUtil.class | ... | ... |