When using Spring4, there is a case where mappingjacksonhttpmessageconverter is not found at run time

Source: Internet
Author: User

Start Project Error:

[Org.springframework.web.context.contextloader]context Initialization Failedorg.springframework.beans.factory.BeanCreationException:
Error creating bean with name'org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter#0' ... ... Caused by:org.springframework.beans.factory.CannotLoadBeanClassException:
Cannot findclass[Org.springframework.http.converter.json.MappingJacksonHttpMessageConverter] forBean with Name'org.springframework.http.converter.json.mappingjacksonhttpmessageconverter#2aa148c0' ... ... Caused by:java.lang.ClassNotFoundException: Org.springframework.http.converter.json.MappingJacksonHttpMessageConverter ...

The reason is spring 3.x and 4. X handles a different class of JSON, which is also configured in an XML file, so it cannot be found at compile time.

Spring3.x is org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.

spring4.x is Org.springframework.http.converter.json.MappingJackson2HttpMessageConverter

1. Find and replace all names in XML

2. Add the latest Fastjackson dependencies at the same time

<Dependency>      <groupId>Com.fasterxml.jackson.core</groupId>      <Artifactid>Jackson-core</Artifactid>      <version>2.8.5</version></Dependency><Dependency>      <groupId>Com.fasterxml.jackson.core</groupId>      <Artifactid>Jackson-databind</Artifactid>      <version>2.8.5</version></Dependency><Dependency>      <groupId>Com.fasterxml.jackson.core</groupId>      <Artifactid>Jackson-annotations</Artifactid>      <version>2.8.5</version></Dependency>

Problem Solving!

When using Spring4, there is a case where mappingjacksonhttpmessageconverter is not found at run time

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.