调试一个maven构建的SSM项目,后端到前端转换成json报如下错:

exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException

Json转换错误:No converter found for return value of type解决办法

解决办法:网上大佬说是json转换错误,所以需要添加依赖,再配置一下springmvc配置文件再重启服务器即可!

pom.xml添加依赖:

  <properties>
    <jackson.version>2.5.4</jackson.version>
  </properties> 

  <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</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>

重启项目,测试:
Json转换错误:No converter found for return value of type解决办法