从 resteasy-jackson-provider 3.9.0 读取 com.fasterxml.jackson.core

问题描述 投票:0回答:0

我们在我们的 vanilla java 项目中使用 Resteasy 3.9.0.Final。我有一个 api 方法,它读取用 Jackson com.fasterxml.jackson.core:jackson-annotations:2.10.0.

 编写的 POJO(
Request

)
    @Override
    @POST
    @GZIP
    @Path("/api")
    public Response call( @HeaderParam("host") @ApiParam(value = "host", required = true) String hostName,
            @ApiParam(value = "", required = true) Request request) {

但是在阅读时我得到了错误-

“detailedErrorMessage”: “{\“messageDetails\“:\“Unrecognized field \\\“id\\\” (Class com.abc.api.platform.xyz.pqr), not marked as ignorable\\n at [Sou
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
    at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
    at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
    at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)

但是当我显式读取字符串中的请求并使用 Fasterxml 的 ObjectMapper 将其转换为

Request
类时,它工作正常。如何强制 api 方法使用 FasterXML ObjectMapper 而不是 CodeHaus 读取 POJO?

我的依赖树中也有这个

[INFO] +- org.jboss.resteasy:resteasy-jackson-provider:jar:3.9.0.Final:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.13:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.9.13:compile

org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile 
org.codehaus.mojo:build-helper-maven-plugin:maven-plugin:3.3.0:compile
java jackson resteasy objectmapper fasterxml
© www.soinside.com 2019 - 2024. All rights reserved.