Springmvc 中org.springframework.http.converter.json.MappingJackson2HttpMessageConverter依赖jackson包

1,问题详情:Spring使用4.3.5.Release版本后

在SpringMvc配置文件中配置json 解析器后出现报错信息

 

[org.springframework.web.context.ContextLoader]Context initialization failed
org.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 find class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter] for bean with name 'org.springframework.http.converter.json.MappingJacksonHttpMessageConverter#2aa148c0' 
... ...
Caused by: java.lang.ClassNotFoundException: org.springframework.http.converter.json.MappingJacksonHttpMessageConverter
    ... ...

 

2.原因:

  Spring4.0后jackson依赖包不一样导致

3.解决方案

Spring 4.x.x版本后使用org.springframework.http.converter.json.MappingJackson2HttpMessageConverter所对应的jar

在maven配置jackson依赖包

 1        <dependency>
 2             <groupId>com.fasterxml.jackson.core</groupId>
 3             <artifactId>jackson-core</artifactId>
 4             <version>2.8.5</version>
 5         </dependency>
 6         <dependency>
 7             <groupId>com.fasterxml.jackson.core</groupId>
 8             <artifactId>jackson-databind</artifactId>
 9             <version>2.8.5</version>
10         </dependency>
11         <dependency>
12             <groupId>com.fasterxml.jackson.core</groupId>
13             <artifactId>jackson-annotations</artifactId>
14             <version>2.8.5</version>
15         </dependency>

 Spring 3.x.x版本后使用org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

 所依赖的jackson包

1         <dependency>
2             <groupId>org.codehaus.jackson</groupId>
3             <artifactId>jackson-mapper-asl</artifactId>
4             <version>1.9.13</version>
5         </dependency>

 

posted @ 2017-08-24 12:34  lonecloud  阅读(...)  评论(...编辑  收藏