SpringMVC 整合Jackson报错

最近用spring4.x整合Jackson,结果莫名其妙的一直报错,网上收索的结果都是在maven或者gradle的环境下配置依赖条件解决的;但是eclipseIDE环境下的jar包应该是会自动依赖影射的。结果一直也没找到可以解决的答案。

后来实在是木有办法了,怀疑到版本的问题了,结果就是版本问题导致的。spring4.x 至少要用Jackson2.6以上才能匹配。

错误如下:

<span style="font-size:18px;">java.lang.ClassNotFoundException: com.fasterxml.jackson.core.util.DefaultIndenter  
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1308)  
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1142)</span>
<span style="font-size:18px;">Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener  
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenter  
    </span> 
<span style="font-size:18px;">Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenter  
</span>  

  把Jackson的包换成2.6以上就能解决了。三个核心包,网上都有的。

 

    原文作者:名白
    原文地址: https://www.cnblogs.com/mingbai/p/6886052.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞