【问题标题】:Spring 4.3.7 is throwing java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenterSpring 4.3.7 抛出 java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenter
【发布时间】:2017-12-17 01:04:27
【问题描述】:

当我从 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

我尝试添加jackson-core

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.8.5</version>
</dependency>

依赖也没有运气

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

谢谢 维诺德

【问题讨论】:

  • DefaultIndenter 类是在 Jackson 2.5 中引入的。也许您项目的其他部分引入了对缺少该类的早期版本的依赖。它可能是通过某些库的传递依赖。尝试运行 mvn dependency:tree 并在输出中查找较旧的 Jackson 版本。
  • 给出你的项目依赖的快照
  • @Sergey/Chris 我们有多模块环境,我们也从其他 pom 继承依赖项。在任何地方我都可以看到 Jackson-core 的依赖项版本是相同的,我将再次清理存储库并更新你们。感谢您的及时回复。

标签: java spring spring-mvc jackson weblogic12c


【解决方案1】:

我遇到了这个问题,使用 Spring 4.3.22.RELEASE 和 jackson-databind 2.2.3,我只需升级到 2.9.8 即​​可解决问题。

【讨论】:

    【解决方案2】:

    如果其他人通过 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>
    

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

    the comment of Chris Nauroth 之后,我使用了mvn dependency:tree,发现Spring Boot 1.x 版本使用了Jackson 2.4.x 版本,而spring-boot-starter 2.x 版本使用Jackson 2.5 或更高版本。

    【讨论】:

      【解决方案3】:

      这对我有用!

      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
      </parent>
      

      【讨论】:

        猜你喜欢
        • 2018-04-26
        • 2020-11-24
        • 2015-08-02
        • 2021-11-10
        • 1970-01-01
        • 2022-09-20
        • 1970-01-01
        • 2021-06-25
        • 2021-10-08
        相关资源
        最近更新 更多