From 788184fc04910bb2075a02a8aba7a62c2f3b02d3 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 1 Dec 2025 14:52:42 +0800 Subject: [PATCH] Fix: Remove deprecated CachingConfigurerSupport in CustomRedisCacheManager --- .../basic/config/CustomRedisCacheManager.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/ycwl/basic/config/CustomRedisCacheManager.java b/src/main/java/com/ycwl/basic/config/CustomRedisCacheManager.java index dcbe1de2..3a1587b5 100644 --- a/src/main/java/com/ycwl/basic/config/CustomRedisCacheManager.java +++ b/src/main/java/com/ycwl/basic/config/CustomRedisCacheManager.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator; import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; -import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -24,19 +24,12 @@ import java.time.Duration; */ @Configuration @EnableCaching -public class CustomRedisCacheManager extends CachingConfigurerSupport { +public class CustomRedisCacheManager { + @Autowired + private ObjectMapper objectMapper; @Bean public RedisCacheConfiguration redisCacheConfiguration() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.registerModule(new JavaTimeModule()); - - // Configure type handling to prevent ClassCastException - PolymorphicTypeValidator typeValidator = BasicPolymorphicTypeValidator.builder() - .allowIfBaseType(Object.class) - .build(); - objectMapper.activateDefaultTyping(typeValidator, ObjectMapper.DefaultTyping.NON_FINAL); - Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(objectMapper, Object.class); RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();