• 170524、java.lang.IllegalArgumentException: No converter found for return value of type异常解决


    错误原因及解决步骤

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

      2.解决步骤:

        手动添加jackson依赖到pom.xml文件中

      <properties>
        <jackson.version>2.9.0</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>

    这样我们就完美解决了该问题。

  • 相关阅读:
    ZROI2018提高day9t1
    p2114 起床困难综合症
    EZOJ #78
    Linux JDK配置
    jps命令
    虚拟机 网卡模式配置
    redhat下yum命令安装(替换为centos yum命令)
    URL编码
    Query DSL(2)----Full text queries
    Query DSL(1)
  • 原文地址:https://www.cnblogs.com/zrbfree/p/7263484.html
Copyright © 2020-2023  润新知