I am trying to do the Rest Get call using oAuth2RestTemplate.getForEntity to service and expecting json reply to be mapped in one of my model class but as the mapping class uses local date (Java 8 concept) I am getting the below error at the time of desterilization :
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value ('1988-02-08')
at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@96ce9eb2; line: 1,
Here is the snippet of my code :
ResponseEntity<Some mapping class> response = this.oAuth2RestTemplate.getForEntity(this.ServiceUrl, Some mapping class.class, inputParameter);
I am aware that this is happening because my model class maps birth date in local date which is introduced in java 8 and my oAuth2RestTemplate is not supporting it. using below code solves the problem
ObjectMapper mapperObj = new ObjectMapper();
mapperObj.registerModule(new JavaTimeModule());
mapperObj.disable(WRITE_DATES_AS_TIMESTAMPS);
but in this case I need to take my service response in string and then I will need to convert it. I need a solution with oAuth2RestTemplate.Can someone help.