When I am migrating from spring 4.3.4 to 4.3.7 I am facing NoclassDefined error after adding Jackson-core dependency
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
I tried to add jackson-core
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.5</version>
</dependency>
dependency also but no luck
Any one who can shed some light on this would be appreciated.
Thanks Vinod
If someone else found this through Google and if You are using SpringBoot
, here is what solved the problem for me. Try setting the parent of Your pom file (i.e. Maven project):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
This will set the spring-boot-starter
version to 2.0.2
, and not the 1.x
, which was default (at least for me).
Following the comment of Chris Nauroth, I've used the mvn dependency:tree
and saw that the 1.x
version of SpringBoot used the 2.4.x
version of Jackson
, whereas spring-boot-starter
version 2.x
uses Jackson 2.5
or higher.
I had this problem, with Spring 4.3.22.RELEASE and jackson-databind 2.2.3, I only had to upgrade to 2.9.8 and problem solved.
来源:https://stackoverflow.com/questions/45060443/spring-4-3-7-is-throwing-java-lang-noclassdeffounderror-com-fasterxml-jackson-c