线程“main”中的异常 java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27746750/
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
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.Hymanson.core.JsonFactory.requiresPropertyOrdering()Z
提问by jbakirov
I need to convert json to pojo. I Decided to use Hymanson and have added Hymanson-core-2.2.0.jar, Hymanson-databind-2.4.4.jar and Hymanson-annotations-2.1.2.jar to my project's classpath
我需要将 json 转换为 pojo。我决定使用 Hymanson 并将 Hymanson-core-2.2.0.jar、Hymanson-databind-2.4.4.jar 和 Hymanson-annotations-2.1.2.jar 添加到我的项目的类路径中
I created following Main
class:
我创建了以下Main
课程:
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import com.fasterxml.Hymanson.core.JsonGenerationException;
import com.fasterxml.Hymanson.core.JsonProcessingException;
import com.fasterxml.Hymanson.databind.JsonMappingException;
import com.fasterxml.Hymanson.databind.JsonNode;
import com.fasterxml.Hymanson.databind.ObjectMapper;
import com.fasterxml.Hymanson.core.JsonGenerationException;
import com.fasterxml.Hymanson.core.type.TypeReference;
import com.fasterxml.Hymanson.databind.JsonMappingException;
import com.fasterxml.Hymanson.databind.ObjectMapper;
import com.fasterxml.Hymanson.databind.DeserializationFeature;
public class Json {
private static String SRC= "";
public static void main(String[] args) {
AwardList awardList = null;
ObjectMapper mapper = new ObjectMapper();
try{
awardList = (AwardList) mapper.readValue(new URL(SRC), AwardList.class);
}catch (JsonGenerationException e){
e.printStackTrace();
} catch (JsonMappingException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
System.out.println(awardList);
}
}
And following AwardList
class:
以及以下AwardList
课程:
public class AwardList {
private Flights[] flights;
private String[] connections;
private SaverEconomy saverEconomy;
private StandartEconomy standartEconomy;
private SaverBusiness saverBusiness;
private StandartFirst standartFirst;
private SaverFirst saverFirst;
public Flights[] getFlights() {
return flights;
}
public void setFlights(Flights[] flights) {
this.flights = flights;
}
public SaverEconomy getSaverEconomy() {
return saverEconomy;
}
public void setSaverEconomy(SaverEconomy saverEconomy) {
this.saverEconomy = saverEconomy;
}
public StandartEconomy getStandartEconomy() {
return standartEconomy;
}
public void setStandartEconomy(StandartEconomy standartEconomy) {
this.standartEconomy = standartEconomy;
}
public SaverBusiness getSaverBusiness() {
return saverBusiness;
}
public void setSaverBusiness(SaverBusiness saverBusiness) {
this.saverBusiness = saverBusiness;
}
public StandartFirst getStandartFirst() {
return standartFirst;
}
public void setStandartFirst(StandartFirst standartFirst) {
this.standartFirst = standartFirst;
}
public SaverFirst getSaverFirst() {
return saverFirst;
}
public void setSaverFirst(SaverFirst saverFirst) {
this.saverFirst = saverFirst;
}
public String[] getConnections() {
return connections;
}
public void setConnections(String[] connections) {
this.connections = connections;
}
}
I want to convert json to pojo and save it in the database. I keep getting following error:
我想将 json 转换为 pojo 并将其保存在数据库中。我不断收到以下错误:
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.Hymanson.core.JsonFactory.requiresPropertyOrdering()Z at com.fasterxml.Hymanson.databind.ObjectMapper.<init>(ObjectMapper.java:457) at com.fasterxml.Hymanson.databind.ObjectMapper.<init>(ObjectMapper.java:379) at Json.main(Json.java:72)
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.Hymanson.core.JsonFactory.requiresPropertyOrdering()Z at com.fasterxml.Hymanson.databind.ObjectMapper.<init>(ObjectMapper.java:457) at com.fasterxml.Hymanson.databind.ObjectMapper.<init>(ObjectMapper.java:379) at Json.main(Json.java:72)
采纳答案by Priya Aggarwal
I was getting the exactly same issue. I was using Maven for dependency management and had added dependency for Hymanson-databind module only like this
我遇到了完全相同的问题。我正在使用 Maven 进行依赖管理,并且只像这样为 Hymanson-databind 模块添加了依赖
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-databind</artifactId>
<version>${Hymanson.version}</version>
</dependency>
and then I resolved it by doing this.. I added its transitive dependencies explicitly with the same Hymanson.version mentioned for each of them in the pom.xml file, as guided here
然后我通过这样做解决了它..我按照在 pom.xml 文件中为每个人提到的相同 Hymanson.version 显式添加了它的传递依赖项,如指导here
<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>
回答by Tobias Gassmann
I had the same issue. There was some incompatibility between the Hymanson-version 2.6.3 and another dependency (graphaware-framework-embedded).
我遇到过同样的问题。Hymanson-version 2.6.3 和另一个依赖项(graphaware-framework-embedded)之间存在一些不兼容。
I could resolve the issue by simply removing the dependency on Hymansonin my own pom and just let the other dependency load whatever Hymanson-version it needed.
我可以通过简单地在我自己的 pom 中删除对 jackson 的依赖来解决这个问题,并让其他依赖加载它需要的任何 Hymanson 版本。
回答by Jeffrey Hawkins
I came here with a similar issue on Google App Engine. Here is how I fixed it.
我在 Google App Engine 上遇到了类似的问题。这是我修复它的方法。
First I ran:
首先我跑了:
mvn dependency:tree
To find who is using the older version. I then excluded that from the offending dependency like so:
查找谁在使用旧版本。然后我将其从有问题的依赖项中排除,如下所示:
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.6</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Next I added the newer version of the dependency in my pom.xml:
接下来,我在 pom.xml 中添加了更新版本的依赖项:
<dependency>
<groupId>com.fasterxml.Hymanson.core</groupId>
<artifactId>Hymanson-core</artifactId>
<version>2.8.7</version>
</dependency>
Hope this help others who stumble here.
希望这能帮助其他在这里绊倒的人。
回答by mrana
I faced the same issue just now while upgrading my project from spring 3 to 4.1.6.
我刚刚在将我的项目从 spring 3 升级到 4.1.6 时遇到了同样的问题。
A little background for reference, just in case if it helps anyone running into same issue===> First, it prompted me with error for mappingHymansonconverter vs mappingHymanson2converter since the former doesn't exist anymore with spring 4. Once I changed those references in code, I ran into issue with my dispatcher servlet since it had xsd definitions from spring 3 support. Once that's corrected, my last step in journey was this error which you all faced as well.
一些参考背景,以防万一它可以帮助任何遇到相同问题的人===> 首先,它提示我 mappingHymansonconverter 与 mappingHymanson2converter 的错误,因为前者在 spring 4 中不再存在。一旦我更改了这些引用代码,我遇到了调度程序 servlet 的问题,因为它具有来自 spring 3 支持的 xsd 定义。一旦纠正,我旅程的最后一步就是你们都面临的这个错误。
My solution: I had older versions of following jars: Hymanson-annotations, Hymanson-core, Hymanson-databind, Hymanson-core-asl, Hymanson-mapper-asl
我的解决方案:我有以下 jars 的旧版本:Hymanson-annotations、Hymanson-core、Hymanson-databind、Hymanson-core-asl、Hymanson-mapper-asl
I upgraded first 3 jars to 2.10.0.pr1 release and last 2 to 1.9.13 release.
我将前 3 个 jar 升级到 2.10.0.pr1 版本,最后 2 个升级到 1.9.13 版本。
I also had one more older jar i.e.com.fasterxml.Hymanson.core.jar which I had to remove as well. Anyways, as error suggested this was the key reason for the mismatch (Like Tobias said in comment prior to mine)
我还有一个更旧的 jar iecom.fasterxml.Hymanson.core.jar,我也不得不将其删除。无论如何,错误表明这是不匹配的关键原因(就像托比亚斯在我之前的评论中所说的那样)
I think only last paragraph is important from this particular question point of view, but I am hoping my narration of issues faced leading up to that may help someone saving 4-5 hrs :) Cheers, folks!
我认为从这个特定问题的角度来看,只有最后一段很重要,但我希望我对面临的问题的叙述可以帮助某人节省 4-5 小时 :) 干杯,伙计们!