栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

解决jackson版本和springboot版本不兼容的问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

解决jackson版本和springboot版本不兼容的问题

一、错误搭配

错误搭配一:


     org.springframework.boot
     spring-boot-starter-parent
     2.1.13.RELEASE



     com.fasterxml.jackson.core
     jackson-databind
     2.11.2

springboot启动时报错:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectMapper' defined in class path resource [com/poizon/fusion/webmvc/core/configuration/FusionWebMvcConfigurer.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.fasterxml.jackson.databind.ObjectMapper] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

错误搭配二:


     org.springframework.boot
     spring-boot-starter-parent
     2.3.10.RELEASE



     com.fasterxml.jackson.core
     jackson-databind
     2.9.10.8

springboot启动时报错:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'formContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]: Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBean

原因:jackson版本和springboot版本不兼容

二、正确搭配

正确搭配一:


     org.springframework.boot
     spring-boot-starter-parent
     2.1.13.RELEASE



     com.fasterxml.jackson.core
     jackson-databind
     2.9.10.8

正确搭配二:


     org.springframework.boot
     spring-boot-starter-parent
     2.3.10.RELEASE



     com.fasterxml.jackson.core
     jackson-databind
     2.11.2

建议:jackson最好使用2.11.0及以上版本
理由:
1、jackson-databind < 2.9.10.8,存在反序列化远程代码执行漏洞(CVE-2020-35490/CVE-2020-35491),远程攻击者可通过精心构造的恶意载荷利用该漏洞在系统执行任意代码;
2、jackson-databind 2.11.0及以上版本与spring-boot版本兼容。

【本文参考】https://blog.csdn.net/wyk_dao/article/details/108729819

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/926568.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号