JPA JAXRS JSON 绑定反序列化错误

JPA JAXRS JSON Binding deserialization error

我在通过 REST 反序列化 JSON 字符串时遇到了一些问题。 我的问题是我总是得到 "JSON Binding deserialization error" 回复。 使用 Chrome 调用时的 JSON 字符串将以我想要的正常方式显示。但是当我想调用方法时,我得到了错误。

获取 REST 方法

public void getFilm(int id) throws IOException {
    Client client = ClientBuilder.newClient();
    WebTarget webTarget = client.target("http://localhost:8080/sprint-3- 
    gruppe-1/api/actors/1");

    Invocation.Builder invocationBuilder 
      = webTarget.request(MediaType.APPLICATION_JSON);

    Response response = invocationBuilder.get();

    ActorDTO temp = response.readEntity(ActorDTO.class);
}

RestAPI

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Response httpGetActor(@PathParam("id") int id) {
    Actor temp = actorService.read(id);
    if(temp == null)  {
        return Response.ok().entity("404 NOT FOUND").build();
    } else {
        return Response.ok().entity(new ActorDTO(temp)).build();
    }
}

ActorDTO

public class ActorDTO {
private int actorId;
private String firstName;
private String lastName;    
private Date lastUpdate;

private ActorDTO() {

}

public ActorDTO(Actor actor) {
    this.actorId = actor.getActorId();
    this.firstName = actor.getFirstName();
    this.lastName = actor.getLastName();
    this.lastUpdate = actor.getLastUpdate();
}
//getter & setters

我解决了我的问题。似乎 Wildfly 14 在 "resteasy-json-binding-provider-3.6.1.Final.jar" 方面存在问题。要解决此问题,您已在加载时忽略它。

解决方法如下: https://developer.jboss.org/thread/278678