title: Spring Boot Deserialize ResponseEntity for REDIS
body: <p>When my code try to deserialize ResponseEntity to REDIS i have this error:</p>
  
  <p>nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of <strong>org.springframework.http.ResponseEntity</strong>: no suitable constructor found, can not deserialize from Object value (<strong>missing default constructor</strong> or creator, or perhaps need to add/enable type information?)</p>
  
  <p><strong>My Controller:</strong></p>
  
  <pre><code>@Cacheable(value = "restapi", keyGenerator = "customKeyGenerator")
      @RequestMapping(value = "/restapi/{id}", method = RequestMethod.GET, produces = { "application/json;charset=UTF-8" })
      @ResponseStatus(HttpStatus.OK)
  
      public ResponseEntity&lt;Object&gt; findRestApi(@PathVariable("id") Integer id) {
  
          RestModel model= new RestModel ();
  
          model = restService.findRestById(id);
  
          return new ResponseEntity&lt;&gt;(produto, headers, HttpStatus.OK);
  }
  </code></pre>
  
  <p><strong>My Redis Configuration Class</strong></p>
  
  <pre><code>@Configuration
  @EnableCaching
  public class CacheConfig extends CachingConfigurerSupport {
  
      @Value("${spring.redis.host}")
      private String host;
      @Value("${spring.redis.port}")
      private Integer port;
  
      @Bean
      public JedisConnectionFactory redisConnectionFactory() {
          JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
          redisConnectionFactory.setHostName(host);
          redisConnectionFactory.setPort(port);
          return redisConnectionFactory;
      }
  
      @Bean
      RedisTemplate&lt;String, Object&gt; redisTemplate(RedisConnectionFactory rcf) {
  
          RedisTemplate&lt;String, Object&gt; template = new RedisTemplate&lt;&gt;();
          template.setConnectionFactory(rcf);
          template.setKeySerializer(new StringRedisSerializer());
          template.setValueSerializer(new JsonRedisSerializer());
  
          return template;
      }
  
      static class JsonRedisSerializer implements RedisSerializer&lt;Object&gt; {
  
          private final ObjectMapper om;
  
          public JsonRedisSerializer() {
              this.om = new ObjectMapper().enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY);
          }
  
          @Override
          public byte[] serialize(Object t) throws SerializationException {
              try {
                  return om.writeValueAsBytes(t);
              } catch (JsonProcessingException e) {
                  throw new SerializationException(e.getMessage(), e);
              }
          }
  
          @Override
          public Object deserialize(byte[] bytes) throws SerializationException {
  
              if(bytes == null){
                  return null;
              }
  
              try {
                  return om.readValue(bytes, Object.class);
              } catch (Exception e) {
                  throw new SerializationException(e.getMessage(), e);
              }
          }
      }
  
      @Bean
      public CacheManager cacheManager(RedisTemplate redisTemplate) {
          RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
          cacheManager.setDefaultExpiration(300);
          return cacheManager;
      }
  
      @Bean
      public KeyGenerator customKeyGenerator() {
          return new KeyGenerator() {
              @Override
              public Object generate(Object o, Method method, Object... objects) {
                  StringBuilder sb = new StringBuilder();
                  sb.append(o.getClass().getName());
                  sb.append(method.getName());
                  for (Object obj : objects) {
                      sb.append(obj.toString());
                  }
                  return sb.toString();
              }
          };
      }
  }
  </code></pre>
  
  <p>Someone know what i can do? Thanks!!</p>