Exception starting Spring application from Java

后端 未结 6 1028
陌清茗
陌清茗 2020-12-03 03:27

I am able to compile and start my Spring project using Maven:

mvn -e clean compile exec:java -Dexec.mainClass=de.fraunhofer.fkie.tet.vmware.manager.Test
         


        
6条回答
  •  Happy的楠姐
    2020-12-03 04:15

    As it suggests there is a problem with the parsing either in Request or in Response. This error can occur if the RestTemplate client is expecting particular kind of Response from the Resource, but the Resource is returning something entirely. I got this error for a POST RestTemplate client that was related to change in the Response returned.

    For e.g. Initial RestTemplate that was returning an Entity 'MyClass' changed and stared returning String so the Parser started giving error

     ResponseEntity postResponseEntity = restTemplate.postForEntity(postEndPoint, httpRequestEntity, MyClass.class);
     MyClass postResponseBody = postResponseEntity.getBody();
    

    Changed to

     ResponseEntity postResponseEntity = restTemplate.postForEntity(postEndPoint, httpRequestEntity, String.class);
     String postResponseBody = postResponseEntity.getBody();
    

    As the response type changed from the entity to String the parser started giving error when processing the Response. Changed it to correct Response type (which in my case was String) and it started working.

提交回复
热议问题