由 java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/Module 在 IntelIj 的 spring 启动项目中引起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47511572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
caused by java.lang.NoClassDefFoundError: com/fasterxml/Hymanson/databind/Module in spring starter project in IntelIj
提问by Programmer
In my spring starter project, I am trying to do API calls using the JPA. My pom.xml
look like this:
在我的 spring 启动项目中,我尝试使用 JPA 进行 API 调用。我的pom.xml
样子是这样的:
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
When I try to run it is getting error as
当我尝试运行它时出现错误
java.lang.NoClassDefFoundError: com/fasterxml/Hymanson/databind/Module
java.lang.NoClassDefFoundError: com/fasterxml/Hymanson/databind/Module
I have searched a lot for this. But could not find exact solution. Please any one help me to resolve this. Thanks in advance.
我为此搜索了很多。但找不到确切的解决方案。请任何人帮我解决这个问题。提前致谢。
回答by helospark
spring-boot-starter-web
already includes Hymanson. You should not override the managed version, otherwise the versions can be different between different Hymanson libraries, causing ClassNotFoundException.
spring-boot-starter-web
已经包括Hyman逊。您不应覆盖托管版本,否则不同 Hymanson 库之间的版本可能不同,从而导致 ClassNotFoundException。
Remove this from the pom:
从 pom 中删除它:
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>2.8.5</version>
</dependency>
and let the transitive dependency with the correct version be used.
并让使用正确版本的传递依赖项。
Or when you add Hymanson to your pom, just don't use any version number, since parent project dependency management already includes all Hymanson libraries with a consistent version.
或者当你将 Hymanson 添加到你的 pom 时,不要使用任何版本号,因为父项目依赖管理已经包含所有具有一致版本的 Hymanson 库。
回答by Vladimir Vivi
Try 2 options :
尝试 2 个选项:
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>2.8.8</version>
or
或者
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>2.7.3</version>