java - Spring-boot using RestTemplate -
i'm trying use resttemplate class spring framework hit restful endpoint. when debug program, every time hit following statement final resttemplate resttemplate = new resttemplate();
, following error appears in console.
connected target vm, address: '127.0.0.1:50055', transport: 'socket' disconnected target vm, address: '127.0.0.1:50055', transport: 'socket' exception in thread "main" java.lang.noclassdeffounderror: org/springframework/beans/fatalbeanexception @ org.springframework.http.converter.json.mappingjackson2httpmessageconverter.<init>(mappingjackson2httpmessageconverter.java:57) @ org.springframework.http.converter.support.allencompassingformhttpmessageconverter.<init>(allencompassingformhttpmessageconverter.java:61) ...
here entire code
// set endpoint final string url = "https://xxxxxxx/api/yyyyyy"; // set content-type header final httpheaders requestheaders = new httpheaders(); requestheaders.setcontenttype(new mediatype("application","xml")); final httpentity<requesttype> requestentity = new httpentity<requesttype>(request, requestheaders); // create new resttemplate instance final resttemplate resttemplate = new resttemplate(); // add jaxb2 message converters resttemplate.getmessageconverters().add(new jaxb2rootelementhttpmessageconverter()); resttemplate.getmessageconverters().add(new bytearrayhttpmessageconverter()); resttemplate.getmessageconverters().add(new stringhttpmessageconverter()); resttemplate.getmessageconverters().add(new resourcehttpmessageconverter()); resttemplate.getmessageconverters().add(new sourcehttpmessageconverter()); resttemplate.getmessageconverters().add(new allencompassingformhttpmessageconverter()); // make http post request, marshaling request json, , response string responseentity<responsetype> responseentity = resttemplate .exchange(url, httpmethod.post, requestentity, responsetype.class); final responsetype inforesponse = responseentity.getbody();
could please me fix error ?
Comments
Post a Comment