Spring boot 如何对Redis的响应进行反序列化?
我正在组织中创建自定义缓存架构,并且必须序列化ResponseEntity对象。我使用GenericJackson2JsonRedisSerializer来序列化对象,但是当它是ResponseEntity时,它不接受 带有Jackson序列化程序的自定义redis模板:Spring boot 如何对Redis的响应进行反序列化?,spring-boot,redis,spring-data-redis,Spring Boot,Redis,Spring Data Redis,我正在组织中创建自定义缓存架构,并且必须序列化ResponseEntity对象。我使用GenericJackson2JsonRedisSerializer来序列化对象,但是当它是ResponseEntity时,它不接受 带有Jackson序列化程序的自定义redis模板: @Bean public RedisTemplate<String, Object> redisTemplate() { RedisTemplate<String, Object&g
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new CustomRedisTemplate<String, Object>();
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setConnectionFactory(jedisConnectionFactory());
return template;
}
反序列化对象时出现问题,有人知道我可以做什么吗?尝试在返回语句中添加类型信息:
return new ResponseEntity<String>("bar", HttpStatus.OK);
返回新的响应属性(“bar”,HttpStatus.OK);
我也有同样的问题。您找到解决方案了吗?您找到解决方案了吗?不幸的是,没有:/
Could not read JSON: Can not construct instance of org.springframework.http.ResponseEntity: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [B@74297a01; line: 1, column: 137] (through reference chain: br.com.stilingue.cloudutilities.cache.CacheItem["value"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.http.ResponseEntity: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [B@74297a01; line: 1, column: 137] (through reference chain: br.com.stilingue.cloudutilities.cache.CacheItem["value"])
return new ResponseEntity<String>("bar", HttpStatus.OK);