if use @Cacheable for return value 'ResponseEntity',I got serialization error.
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]
demo:
@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) {
//....
}
}
Cache objects should be Serializable but ResponseEntity is not Serializable.
You could add cache on the different level, so it would be possible to make return type serializable or add some customer serializer/deserializer which would be able to save ResponseEntity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With