如果使用@Cacheable 返回值'ResponseEntity',我得到序列化错误。
Caused by: 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 [org.springframework.http.ResponseEntity]
演示:</p>
@Controller
@CacheConfig(cacheNames = "logs")
public class LogController {
@Cacheable(key = "#id")
@RequestMapping(value = LogConstants.LOGS_ID_PATH, method = RequestMethod.GET)
public ResponseEntity<Log> findById(@PathVariable Long id) {
//....
}
}