No converter found for return value of type

半世苍凉 提交于 2020-01-09 23:54:54

springMVC请求接口的时候报500  No converter found for return value of type

原因:这是因为springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖。

<dependency>    <groupId>com.fasterxml.jackson.core</groupId>    <artifactId>jackson-core</artifactId>    <version>2.5.4</version></dependency><dependency>    <groupId>com.fasterxml.jackson.core</groupId>    <artifactId>jackson-databind</artifactId>    <version>2.5.4</version></dependency>

如果还是没有解决,则进行以下步骤

在springmvc配置文件中进行如下配置

<mvc:annotation-driven>
     <mvc:message-converters>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
   </mvc:message-converters>
</mvc:annotation-driven>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!