我有一个基于 Thorntail 和 Microprofile 的小型服务。看起来很简单——在 POST 请求中获取 JSON 做一些事情,返回响应。但是问题是,在 POJO 中,我有一个LocalDateTime
字段并且出现了问题,这是我得到的响应
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct
instance of `java.time.LocalDateTime` (no Creators, like default construct,
exist): no String-argument constructor/factory method to deserialize from
String value ('2020-04-28T04:10:48.020Z')
at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 1,
column: 496] (through reference chain:
com.ainq.pulse.audit.model.UserAuditEvent["timestamp"])
为什么它使用 Jackson 而不是 Jsonb provider ?
在日志中,我收到以下消息(除其他外)
2020-04-28 10:19:37,235 WARN [org.jboss.as.jaxrs] (MSC service thread 1-6)
WFLYRS0018: Explicit usage of Jackson annotation in a JAX-RS deployment; the
system will disable JSON-B processing for the current deployment. Consider
setting the 'resteasy.preferJacksonOverJsonB' property to 'false' to restore
JSON-B.
我在哪里设置这个resteasy.preferJacksonOverJsonB
属性?
我试图在 中设置属性project-defaults.yml
,我试图作为-D
参数提供,但似乎没有任何效果,我仍然收到此消息,并且(反)序列化仍然存在问题。
修复它的方法是什么?我查看了文档、示例甚至源代码,仍然想知道什么会起作用。
更新:
相关部分来自dependency:tree
[INFO] +- io.thorntail:microprofile:jar:2.6.0.Final:compile
[INFO] | +- io.thorntail:jaxrs:jar:2.6.0.Final:compile
[INFO] | | +- io.thorntail:jaxrs-cdi:jar:2.6.0.Final:compile
[INFO] | | +- org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.0.Final:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.10:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.1:compile
[INFO] | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.9.10:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.9.10:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.10:compile