Spring Caching的AbstractCacheInvoker doPut()方法误调用了RedisCache的put()方法

Spring Caching's AbstractCacheInvoker doPut() method calls RedisCache put() method by mistake

我有一个用 spring 引导编写的 Web 应用程序,它使用 springframework.cache,在我开始使用 spring-data-redis 之前一切正常。

只要我在 pom.xml 中添加 spring-data-redis,我的 spring 缓存就会开始使用 RedisCache 实现。我想在不同的事情上将 redis 用于 redis 流部分,并以某种方式忽略应用程序缓存部分的 redis 缓存实现

异常类路径:

java.io.NotSerializableException: ...DomainData
assessment-service_1  |         at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:96)
assessment-service_1  |         at org.springframework.data.redis.serializer.DefaultRedisElementWriter.write(DefaultRedisElementWriter.java:43)
assessment-service_1  |         at org.springframework.data.redis.serializer.RedisSerializationContext$SerializationPair.write(RedisSerializationContext.java:287)
assessment-service_1  |         at org.springframework.data.redis.cache.RedisCache.serializeCacheValue(RedisCache.java:244)
assessment-service_1  |         at org.springframework.data.redis.cache.RedisCache.put(RedisCache.java:150)
assessment-service_1  |         at org.springframework.cache.interceptor.AbstractCacheInvoker.doPut(AbstractCacheInvoker.java:87)
assessment-service_1  |         at org.springframework.cache.interceptor.CacheAspectSupport$CachePutRequest.apply(CacheAspectSupport.java:837)
assessment-service_1  |         at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:430)
assessment-service_1  |         at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:346)
assessment-service_1  |         at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
assessment-service_1  |         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
assessment-service_1  |         at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
assessment-service_1  |         at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)

您可能想要明确设置 属性 spring.cache.type,如果检测到 Spring 数据 Redis,它会自动配置为使用 Redis。您可以从 https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/cache/CacheType.html 中选择值或使用 'none' 完全禁用。您可能需要将 spring-boot-starter-cache 添加到您的 POM 以获得基本的缓存实现。