Fix Java.lang.IllegalArgumentException:No converter found for return value of Type:class java.util.ArrayList issue

Source: Internet
Author: User

In the Spring + SPRINGMVC + mybatis Framework, we configured the interface to return JSON format, but reported the following error:

124-oct-2017 17:42:23.495 Serious [http-nio-8080-exec-6] Org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service () forservlet [Dispatcherservlet] in the context with path [] threw exception [Request processing failed; nested exception is JAVA.L Ang. Illegalargumentexception:no Converter found for returnValue of type:classjava.util.ArrayList] with root cause2Java.lang.IllegalArgumentException:No Converter found for returnValue of type:classjava.util.ArrayList3At Org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters (abstractmessageconvertermethodprocessor.java:187)4At Org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue ( requestresponsebodymethodprocessor.java:174)5At Org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue ( handlermethodreturnvaluehandlercomposite.java:81)6At Org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle ( servletinvocablehandlermethod.java:113)7At Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod ( requestmappinghandleradapter.java:827)8At Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal ( requestmappinghandleradapter.java:738)9At Org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle ( Abstracthandlermethodadapter.java:85)TenAt Org.springframework.web.servlet.DispatcherServlet.doDispatch (dispatcherservlet.java:967) OneAt Org.springframework.web.servlet.DispatcherServlet.doService (dispatcherservlet.java:901) AAt Org.springframework.web.servlet.FrameworkServlet.processRequest (frameworkservlet.java:970) -At Org.springframework.web.servlet.FrameworkServlet.doGet (frameworkservlet.java:861) -At Javax.servlet.http.HttpServlet.service (httpservlet.java:622) theAt Org.springframework.web.servlet.FrameworkServlet.service (frameworkservlet.java:846) -At Javax.servlet.http.HttpServlet.service (httpservlet.java:729) -At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:230) -At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:165) +At Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52) -At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:192) +At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:165) AAt Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:197) atAt Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:107) -At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:192) -At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:165) -At Org.apache.catalina.core.StandardWrapperValve.invoke (standardwrappervalve.java:198) -At Org.apache.catalina.core.StandardContextValve.invoke (standardcontextvalve.java:108) -At Org.apache.catalina.authenticator.AuthenticatorBase.invoke (authenticatorbase.java:472) inAt Org.apache.catalina.core.StandardHostValve.invoke (standardhostvalve.java:140) -At Org.apache.catalina.valves.ErrorReportValve.invoke (errorreportvalve.java:79) toAt Org.apache.catalina.valves.AbstractAccessLogValve.invoke (abstractaccesslogvalve.java:620) +At Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:87) -At Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:349) theAt Org.apache.coyote.http11.Http11Processor.service (http11processor.java:784) *At Org.apache.coyote.AbstractProcessorLight.process (abstractprocessorlight.java:66) $At Org.apache.coyote.abstractprotocol$connectionhandler.process (abstractprotocol.java:802)Panax NotoginsengAt Org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun (nioendpoint.java:1410) -At Org.apache.tomcat.util.net.SocketProcessorBase.run (socketprocessorbase.java:49) theAt Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1142) +At Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:617) AAt Org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run (taskthread.java:61) theAt Java.lang.Thread.run (thread.java:745)

After the degree Niang, because SPRINGMVC default is no object to convert to JSON converter, need to manually add the Jackson dependency.

Therefore, in the Build.gradle, add:

1     Compile group: ' Com.fasterxml.jackson.core ', Name: ' Jackson-core ', version: ' 2.8.8 '2     //  Https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind3     Compile Group : ' Com.fasterxml.jackson.core ', Name: ' Jackson-databind ', version: ' 2.8.8 '4//https:// Mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations5     compile group: ' Com.fasterxml.jackson.core ', Name: ' Jackson-annotations ', version: ' 2.8.8 '

If maven, join:

Manually add Jackson to the Pom.xml file

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

If it is still not resolved, follow these steps

In the SPRINGMVC configuration file, configure the following

<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>

Thank you for the address: http://www.cnblogs.com/hafiz/p/5812873.html blogger.

Fix Java.lang.IllegalArgumentException:No converter found for return value of Type:class java.util.ArrayList issue

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.