java 变量定义 映射_JavaJackson对象映射器在正确的变量名上失败

注意:我知道变量的名称不正确。我正在清理另一个将这些列为成员变量的开发人员的旧代码。它们将被正确命名,是的,我知道我需要注释,但是我在这里要找的是一个解释,为什么变量是employeeid,它在寻找employeeid,但是找到一个不存在的变量mempolyeid。顺便说一句,这发生在服务器上,而不仅仅是在IDE中。

出于某种未知的原因——在修改变量名、保存、重新启动、使缓存无效之后,一切——杰克逊无法映射到propper变量名。我正在使用IntLIJ与Java进行此操作。

错误:

Exception in badge service getting by badgeId: Unrecognized field

"EmployeeId" (class com.companyName.attendance.entity.DTOs.badgeservice.BadgeDTO), not marked as ignorable (6 known properties: "mBadgeId", "mEmployeeId", "mLanId", "mFirstName", "mEmail", "mLastName"])

at [Source: (String)"{"backoff":null,"error_id":null,"error_message":null,"error_name":null,"has_more":false,"items":[{"EmployeeId":"888888","LanId":"NTest","FirstName":"Name","MiddleName":null,"LastName":"Test","Email":null,"Location":null,"Title":null,"Phone":null,"DepartmentId":null,"DepartmentName":null,"DepartmentNumber":null,"Groups":null,"Found":false,"BadgeId":"222222","JobTitle":null,"Picture":null,"OrgUrl":null,"Manager":null,"Coworkers":null,"DirectReports":null}],"page":null,"page_size":null,"quo"[truncated 61 chars]; line: 1, column: 113] (through reference chain: com.companyName.attendance.entity.DTOs.badgeservice.BadgeServiceResponseDTO["items"]->java.util.ArrayList[0]->com.companyName.attendance.entity.DTOs.badgeservice.BadgeDTO["EmployeeId"])

如您所见,在DTO中找不到EmployeeID,并说预期的feild是mempolyeID。但是,这里是我的DTO变量声明:

public class BadgeDTO {

//TODO: Convert member variables to proper practice names

String BadgeId;

String EmployeeId;

String FirstName;

String LanId;

String LastName;

String Email;

public BadgeDTO(String BadgeId, String EmployeeId, String FirstName,

String LanId, String LastName, String Email) {

super();

this.BadgeId = BadgeId;

this.EmployeeId = EmployeeId;

this.FirstName = FirstName;

this.LanId = LanId;

this.LastName = LastName;

this.Email = Email;

}

public BadgeDTO() {

super();

}

public String getmBadgeId() {

return BadgeId;

}

public void setmBadgeId(String BadgeId) {

this.BadgeId = BadgeId;

}

public String getmEmployeeId() {

return EmployeeId;

}

public void setmEmployeeId(String EmployeeId) {

this.EmployeeId = EmployeeId;

}

public String getmFirstname() {

return FirstName;

}

public void setmFirstName(String FirstName) {

this.FirstName = FirstName;

}

public String getmLanId() {

return LanId;

}

public void setmLanId(String LanId) {

this.LanId = LanId;

}

public String getmLastName() {

return LastName;

}

public void setmLastName(String LastName) {

this.LastName = LastName;

}

public String getmEmail() {

return Email;

}

public void setmEmail(String Email) {

this.Email = Email;

}

@Override

public String toString() {

return "BadgeDTO [BadgeId=" + BadgeId + ", EmployeeId=" + EmployeeId +

", Firstname=" + FirstName

+ ", LanId=" + LanId + ", LastName=" + LastName + ", Email=" +

Email + "]";

}

}

现在疯狂的是,做以下工作:

@JsonProperty("BadgeId")

String BadgeId;

@JsonProperty("EmployeeId")

String EmployeeId;

@JsonProperty("FirstName")

String FirstName;

杰森:

{

"backoff": null,

"error_id": null,

"error_message": null,

"error_name": null,

"has_more": false,

"items": [

{

"EmployeeId": "888888",

"LanId": "TName",

"FirstName": "Test",

"MiddleName": null,

"LastName": "Name",

"Email": null,

"Location": null,

"Title": null,

"Phone": null,

"DepartmentId": null,

"DepartmentName": null,

"DepartmentNumber": null,

"Groups": null,

"Found": false,

"BadgeId": "222222",

"JobTitle": null,

"Picture": null,

"OrgUrl": null,

"Manager": null,

"Coworkers": null,

"DirectReports": null

}

],

"page": null,

"page_size": null,

"quota_max": null,

"quota_remaining": null,

"total": null,

"type": null

}

所以,我已经使用上面的JSONproperty注释解决了这个问题,但是为什么它仍然在寻找mempolyeid,当它不存在于我的整个代码中的任何位置时?我认为无效/重新启动可以解决这个问题,但它没有

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值