no suitable HttpMessageConverter found for response type

前端 未结 10 1769
深忆病人
深忆病人 2020-11-30 02:33

Using spring, with this code :

List> messageConverters = restTemplate.getMessageConverters();
for(HttpMessageConverter ht         


        
10条回答
  •  独厮守ぢ
    2020-11-30 02:46

    This is not answering the problem but if anyone comes to this question when they stumble upon this exception of no suitable message converter found, here is my problem and solution.

    In Spring 4.0.9, we were able to send this

        JSONObject jsonCredential = new JSONObject();
        jsonCredential.put(APPLICATION_CREDENTIALS, data);
    
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
    
    ResponseEntity res = restTemplate.exchange(myRestUrl), HttpMethod.POST,request, String.class);
    

    In Spring 4.3.5 release, we starting seeing errors with the message that converter was not found. The way COnverets work is that if you have it in your classpath, they get registered.jackson-asl was still in classpath but was not being recognized by spring. We replace Jackson-asl with faster-xml jackson core. Once we added I could see the converter being registered

提交回复
热议问题