No converter found for return value of type

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>
posted @ 2018-03-07 00:36  guuyoog  Views(352)  Comments(0Edit  收藏  举报