Spring3X升级到Spring4X时,出现的问题

1.1、异常描述

Description Resource    Path    Location    Type
Class 'org.springframework.http.converter.json.MappingJacksonHttpMessageConverter' not found [config set: testweba/web-context] spring-mvc.xml /testweba/src/main/resources line 13 Spring Beans Problem

1.2、原因分析

Spring3升级到Spring4时, 运行时出现找不到MappingJacksonHttpMessageConverter的情况
原因是Spring 3.x 和4.X处理JSON的一个类不一样,而这个东西又配置在xml文件中,所以编译时又无法发现

1.3 解决办法

spring3.x是org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

spring4.x是org.springframework.http.converter.json.MappingJackson2HttpMessageConverter

  1. 查找替换所有XML中名字
  2. 同时加入最新的FastJackson依赖

2.1 异常描述

Description Resource    Path    Location    Type
Build path is incomplete. Cannot find class file for com/fasterxml/jackson/core/JsonGenerator spring-mvc.xml /testweba/src/main/resources line 13 Spring AOP Problem

2.2 原因分析

Spring 4.x 需要依赖的相关FastJackson jar

2.3 解决办法

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.8.0</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.8.8</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.8.8</version>
</dependency>

或者直接引入总的依赖包名

<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-module-jaxb-annotations</artifactId>
    <version>2.8.8</version>
</dependency>

 

转载于:https://www.cnblogs.com/onlymate/p/7677000.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值