问题描述
运行之前能正常的项目出现以上报错,提示创建“formContentFilter”时错误;org.springframework.boot版本2.4.8
org.springframework.beans.factory.BeanCreationException. Message:
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 java.lang.NoClassDefFoundError: Could not initialize class com.fasterxml.jackson.databind.cfg.DatatypeFeatures$DefaultHolder
解决方法
发现是近期单独导入com.fasterxml.jackson.core的jackson-databind时与spring-boot-starter-web中自带的版本冲突导致,直接将版本号修改与spring-boot-starter-web中保持一致,或者直接去掉后过行成功;但在spring-boot-starter-web中使用exclusion排除jackson-databind包报错依然存在;