Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

DefaultSerializer requires a Serializable payload but received an object of type [org.springframework.http.ResponseEntity]

$
0
0

I want to cache the List in redis. Below is the service method for the same:-

@Autowiredprivate RedisTemplate<String, Object> redisTemplate;@Cacheable(value = "notes", key = "#userId")public ResponseEntity<?> getAllNotes(Integer userId) {        HashOperations<String, String, Object> hashOperations = redisTemplate.opsForHash();        //Check if the cacheKey contains this userId        if (hashOperations.hasKey(cacheKey, userIdAsKey)) {            List<NoteResponse> noteResponses = (List<NoteResponse>) hashOperations.get(cacheKey, userIdAsKey);            return ResponseEntity.ok(noteResponses);        }        List<Note> notes = noteRepository.findAllByUserId(userId);        List<NoteResponse> noteResponses = Helper.getNoteResponse(notes);        hashOperations.put(cacheKey, userIdAsKey, noteResponses);        return ResponseEntity.ok(noteResponses);}

but i am getting this exception: java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [org.springframework.http.ResponseEntity]


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>