ObjectMapper java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35094818/
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
ObjectMapper java.lang.NoSuchMethodError: com.fasterxml.Hymanson.core.JsonFactory.requiresPropertyOrdering()Z
提问by William Roberts
I am trying to map a Json string to a Java Object using ObjectMapper
我正在尝试使用 ObjectMapper 将 Json 字符串映射到 Java 对象
ObjectMapper mapper = new ObjectMapper();
CustomerData customerData = mapper.readValue(customerDataString, customerData.class);
But when I do, I get this error
但是当我这样做时,我收到此错误
java.lang.NoSuchMethodError: com.fasterxml.Hymanson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.Hymanson.databind.ObjectMapper.<init>(ObjectMapper.java:530)
I looked online and checked for the incompatible dependencies in the pom.xml, and it appears to be the right version. So what am I missing?
我在网上查看并检查了 pom.xml 中不兼容的依赖项,它似乎是正确的版本。那么我错过了什么?
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-databind</artifactId>
<version>2.6.0</version>
</dependency>
回答by Rainer Montag
Make sure that you do not have an older version of artifactId "Hymanson-core" (< 2.3.0) as a dependency. You can try to add
确保您没有旧版本的 artifactId "Hymanson-core" (< 2.3.0) 作为依赖项。您可以尝试添加
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>2.6.0</version>
</dependency>
as first dependency in your pom.
作为你的 pom.xml 中的第一个依赖项。
回答by Chinthaka Dinadasa
Following dependenciesmust be tally with each other. (Same Version)
以下依赖项必须相互匹配。(同版本)
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-databind</artifactId>
<version>${Hymanson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-annotations</artifactId>
<version>${Hymanson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>${Hymanson.version}</version>
</dependency>