使用restTemplate报错:no suitable HttpMessageConverter found for response type [class java.lang.Object...
mb645b608370ff5
使用restTemplate报错:no suitable HttpMessageConverter found for response type [class java.lang.Object...
首先看一下报错
org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class java.lang.Object] and content type [text/html;charset=utf-8]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:123)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:998)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:981)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:741)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:583)
at com.kfpt.sqlserver.service.analysisPlatform.impl.BindMultiMerchantServiceImpl.unbind(BindMultiMerchantServiceImpl.java:83)
at com.kfpt.sqlserver.service.enterprise.impl.HelperServiceImpl.unbindMultiMerchant(HelperServiceImpl.java:385)
at com.kfpt.sqlserver.service.enterprise.impl.HelperServiceImpl.unbind(HelperServiceImpl.java:352)
at com.kfpt.sqlserver.controller.enterprise.HelperController.unbind(HelperController.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.kfpt.common.filter.TraceFilter.doFilterInternal(TraceFilter.java:43)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.kfpt.common.filter.TenantFilter.doFilterInternal(TenantFilter.java:39)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:124)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
image.png
postman请求是可以的
源码如下
/**
* @param unbindMultiMerchantDtoList
@Override
public void unbind(List<UnbindMultiMerchantDto> unbindMultiMerchantDtoList) {
String url = analysisPlatformUrl + "/Interface/Paas.aspx?Command=UnbindMultiMerchant";
try {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Content-Type", "application/json");
ObjectMapper objectMapper = new ObjectMapper();
log.info("<==微信群聊消息 {}", objectMapper.writeValueAsString(unbindMultiMerchantDtoList));
HttpEntity<List<UnbindMultiMerchantDto>> requestEntity = new HttpEntity<>(unbindMultiMerchantDtoList, requestHeaders);
ResponseEntity<Object> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, Object.class);
log.info("<==商家解绑结果 {}", JSON.toJSONString(response));
} catch (Exception ex) {
log.error("<== 商家解绑失败: {} ", JSON.toJSONString(unbindMultiMerchantDtoList), ex);
}
将返回体的Object换String就可以了
作者:无尘粉笔
上一篇:
Spring事务嵌套引发的血案---Transaction rolled back because it has been marked as rollback-only
下一篇:
spring中单例模式
no suitable HttpMessageConverter found for response type [***] and content type [application/octet-
场景rest请求调用服务的时候报错,报错信息为: org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.test.model.JsonResult] and
OpenFeign问题之 Could not write request: no suitable HttpMessageConverter found for request type wit
问题描述Could not write request: no suitable HttpMessageConverter found for request type with Feign解决方案对于Feign接口
报错 Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type:
Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: text/html - in Resteasy解决办法:<dependency> <groupId>org.jboss.resteasy</groupId>
RestTemplate报错RestTemplate报异常java.lang.IllegalStateException:No instances available for localhost
RestTemplate报异常java.lang.IllegalStateException:No instances available for localhostSpring Cloud RestTemplate报错:java.lang.IllegalStateException: 我不
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
在用eclipse开发中,有时候需要导入别人的项目进行学习研究偶尔会出现代码无端端显示一大推错误,甚至连包名都出错的情况,这是后把鼠标移动到包名,系统就会弹出The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class fi
java.lang.IllegalArgumentException: No converter found for return value of type: class XXX.XXXX
最近项目中用到fastjson做接口数据的转换,发现报这个错误了,环境是springMVC4,看到阿里的官网说是“ 如果是使用 XML 的方式配置 Spring MVC 的话,只需在 Spring MVC 的 XML 配置文件中加入下面配置即可。 <mvc:annotation-driven> <m
eclipse中java文件报错:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
问题:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files 大概意思就是.class文件引用错误, 联想一下 编译出了问题, JRE问题. 解决办法:先