我有一个简单的 jax-rs 休息
@POST
@Path("/user")
@Produces({ "application/json" })
@Consumes({ "application/json" })
public Response createuser(User user){
user.name = "pepebotero";
return Response.ok(user).build();
我们要绑定到 POJO 用户
public class User {
public String name;
public String surname;
}
将 JSON 与对象用户一起使用
{
"User":{
"name":"geroge",
"surname":"jordi"
}
}
我正在寻找一种方法来解决尽可能少的干扰以避免以下错误。我正在寻找面向注释的解决方案
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "User" (class com.endpoint.User), not marked as ignorable (2 known properties: "name", "surname"])
at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@576599b5; line: 2, column: 10] (through reference chain: com..endpoint.User["User"]