我有一个方法:
@Cacheable(key = "#jobId")
public Optional
当我尝试检索缓存的项目时,我收到以下异常:
2016-01-18 00:01:10 ERROR [trace=,span=] http-nio-8021-exec-2 [dispatcherServlet]:182 – Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing Failed; nested exception is org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [java.util.Optional]] with root cause
java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [java.util.Optional]
@Bean
RedisCacheManager redisCacheManager (RedisTemplate
请注意,这只是一个例子,我没有测试这个imeplementation.但我在生产中使用Kryo序列化程序以相同的方式使用Spring进行redis缓存.