Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. String testDocumentJson =
  2. this.restTemplate.postForObject(url, data, String.class);
  3.  
  4. ObjectMapper mapper = new ObjectMapper();
  5.  
  6. PageImpl<TestDocument> resultPage =
  7. mapper.readValue(testDocumentJson,
  8. new TypeReference<TestResponse<TestDocument>>() {});
  9.  
  10. ResponseEntity<TestResponse<TestDocument>> TestDocImplPageResponse =
  11. this.restTemplate.exchange(url, HttpMethod.POST, requestEntity,
  12. new ParameterizedTypeReference<TestResponse<TestDocument>>() {});
  13.  
  14. org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [com.TestResponse<com.model.TestDoc>] and content type [application/json;charset=UTF-8]
  15.  
  16. public class TestResponse<T> extends PageImpl<T> {
  17.  
  18. private int number;
  19. private int size;
  20. private int totalPages;
  21. private int numberOfElements;
  22. private long totalElements;
  23. private boolean previousPage;
  24. private boolean first;
  25. private boolean nextPage;
  26. private boolean last;
  27. private List<T> content;
  28. private Sort sort;
  29.  
  30.  
  31. public TestResponse() {
  32. super(new ArrayList<T>());
  33. }
  34.  
  35. getters and setters
  36.  
  37. }
  38.  
  39. public class TestDocument
  40. {
  41. private String name
  42. ...
  43. fields and getters and setters
  44.  
  45. }
Add Comment
Please, Sign In to add comment