SpringMVC 整合Jackson报错

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

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

错误如下:

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)
	

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
	

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

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

新搬家到csdn,有用请关注啊!

你可能感兴趣的:(Json,spring)