update 调整 CacheManager 使用系统 系统序列化器

feature/model
疯狂的狮子li 3 years ago
parent f668089e64
commit 3a918ae8f6

@ -1,7 +1,7 @@
package com.ruoyi.framework.config; package com.ruoyi.framework.config;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.utils.JsonUtils; import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.config.properties.RedissonProperties; import com.ruoyi.framework.config.properties.RedissonProperties;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -44,9 +44,12 @@ public class RedisConfig extends CachingConfigurerSupport {
@Autowired @Autowired
private RedissonProperties redissonProperties; private RedissonProperties redissonProperties;
@Autowired
private ObjectMapper objectMapper;
@Primary @Primary
@Bean(destroyMethod = "shutdown") @Bean(destroyMethod = "shutdown")
public RedissonClient redisson() { public RedissonClient redisson(RedisProperties redisProperties, RedissonProperties redissonProperties, ObjectMapper objectMapper) {
String prefix = REDIS_PROTOCOL_PREFIX; String prefix = REDIS_PROTOCOL_PREFIX;
if (redisProperties.isSsl()) { if (redisProperties.isSsl()) {
prefix = REDISS_PROTOCOL_PREFIX; prefix = REDISS_PROTOCOL_PREFIX;
@ -54,7 +57,7 @@ public class RedisConfig extends CachingConfigurerSupport {
Config config = new Config(); Config config = new Config();
config.setThreads(redissonProperties.getThreads()) config.setThreads(redissonProperties.getThreads())
.setNettyThreads(redissonProperties.getNettyThreads()) .setNettyThreads(redissonProperties.getNettyThreads())
.setCodec(new JsonJacksonCodec(JsonUtils.getObjectMapper())); .setCodec(new JsonJacksonCodec(objectMapper));
RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig(); RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig();
if (ObjectUtil.isNotNull(singleServerConfig)) { if (ObjectUtil.isNotNull(singleServerConfig)) {
@ -113,7 +116,7 @@ public class RedisConfig extends CachingConfigurerSupport {
cacheConfig.setMaxSize(group.getMaxSize()); cacheConfig.setMaxSize(group.getMaxSize());
config.put(group.getGroupId(), cacheConfig); config.put(group.getGroupId(), cacheConfig);
} }
return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE); return new RedissonSpringCacheManager(redissonClient, config, new JsonJacksonCodec(objectMapper));
} }
/** /**

Loading…
Cancel
Save