gpt4 book ai didi

java - ObjectMapper java.lang.NoSuchMethodError : com. fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:44:25 26 4
gpt4 key购买 nike

我正在尝试使用 ObjectMapper 将 Json 字符串映射到 Java 对象

ObjectMapper mapper = new ObjectMapper();
CustomerData customerData = mapper.readValue(customerDataString, customerData.class);

但是当我这样做的时候,我得到了这个错误

java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:530)

我在网上查看并检查了 pom.xml 中的不兼容依赖项,它似乎是正确的版本。那我错过了什么?

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

最佳答案

以下依赖项必须相互匹配。 (相同版本)

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>

关于java - ObjectMapper java.lang.NoSuchMethodError : com. fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35094818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com