From 21a2c849e80ccf5e96d1349523db465e210101d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 13 May 2022 09:39:26 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=B0=83=E6=95=B4=20CacheManager=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=B3=BB=E7=BB=9F=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/redis/config/RedisConfiguration.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/config/RedisConfiguration.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/config/RedisConfiguration.java index 0dbe3841..4d53bc1b 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/config/RedisConfiguration.java +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/config/RedisConfiguration.java @@ -1,7 +1,7 @@ package com.ruoyi.common.redis.config; import cn.hutool.core.util.ObjectUtil; -import com.ruoyi.common.core.utils.JsonUtils; +import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.redis.config.properties.RedissonProperties; import lombok.extern.slf4j.Slf4j; @@ -49,6 +49,9 @@ public class RedisConfiguration extends CachingConfigurerSupport { @Autowired private RedissonProperties redissonProperties; + @Autowired + private ObjectMapper objectMapper; + @Primary @Bean(destroyMethod = "shutdown") public RedissonClient redisson() { @@ -59,7 +62,7 @@ public class RedisConfiguration extends CachingConfigurerSupport { Config config = new Config(); config.setThreads(redissonProperties.getThreads()) .setNettyThreads(redissonProperties.getNettyThreads()) - .setCodec(new JsonJacksonCodec(JsonUtils.getObjectMapper())); + .setCodec(new JsonJacksonCodec(objectMapper)); RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig(); if (ObjectUtil.isNotNull(singleServerConfig)) { @@ -118,7 +121,7 @@ public class RedisConfiguration extends CachingConfigurerSupport { cacheConfig.setMaxSize(group.getMaxSize()); config.put(group.getGroupId(), cacheConfig); } - return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE); + return new RedissonSpringCacheManager(redissonClient, config, new JsonJacksonCodec(objectMapper)); } /**