No converter for XXX with preset Content-Type ‘application/octet-stream;charset=UTF-8‘
在导出excel中返回公共封装类BaseResposne数据报错没有转换器,项目中把返回值改了void
其他原因是如下解决
解决办法
方法一:将FastJson更换为jackson-databind
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.4</version>
</dependency>
<!--
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.75</version>
</dependency>
-->
方法二:为RestTemplate添加HttpMessageConverter
在Spring配置文件中修改
注:这种方式只会注册你列表中有的Http消息转换器,没有的不会进行注册
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="formHttpMessageConverter"/>
<ref bean="fastJs