Spring 4.3.7抛出java.lang.NoClassDefFoundError:com/fasterxml/jackson/core/util/DefaultIndenter

Vin*_*ale 9 java spring spring-mvc jackson weblogic12c

当我从spring 4.3.4迁移到4.3.7时,我在添加Jackson-core依赖后面临NoclassDefined错误

引发者:org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:构造函数抛出异常; 嵌套异常是java.lang.NoClassDefFoundError:com/fasterxml/jackson/core/util/DefaultIndenter

我试着添加杰克逊核心

<dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>2.8.5</version>
            </dependency>
Run Code Online (Sandbox Code Playgroud)

依赖也没有运气

任何能够对此有所了解的人都将不胜感激.

谢谢Vinod

Ale*_*dar 0

如果其他人通过 Google 发现了这个,并且您正在使用 Spring Boot,那么这就是为我解决问题的方法。尝试设置您的 pom 文件(即 Maven 项目)的父级:

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.2.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)

这会将版本设置spring-boot-starter为 2.0.2,而不是默认的 1.x(至少对我来说)。

根据Chris Nauroth 的评论,我使用了mvn dependency:treeSpring Boot 的 1.x 版本,使用了 Jackson 的 2.4.x 版本,而spring-boot-starter2.x 版本使用了 Jackson 2.5 或更高版本。