[英]JsonMappingException can not deserialize instance of java.lang.Integer
I am trying to insert object in my database but i am getting this error 我正在尝试在数据库中插入对象,但出现此错误
Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of java.lang.Integer out of VALUE_TRUE token
at [Source: java.io.PushbackInputStream@745b0b15; line: 1, column: 353] (through reference chain: com.example.beans.Domain["isActive"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.Integer out of VALUE_TRUE token
at [Source: java.io.PushbackInputStream@745b0b15; line: 1, column: 353] (through reference chain: com.example.beans.Domain["isActive"])
my code is: 我的代码是:
@Entity
public class Domain implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
...
private Integer isActive;
public Integer getIs_active() {
return isActive;
}
public void setIs_active(Integer is_active) {
this.isActive = is_active;
}
I believe your JSON for isActive is of boolean isActive : true
It is expecting to be of type boolean not integer. 我相信您的isActive的JSON为boolean
isActive : true
期望为boolean类型而不是整数。 This is makes your Jackson 这是让你的杰克逊
Change your private Integer isActive;
更改您的
private Integer isActive;
to private boolean isActive;
private boolean isActive;
Your getter and setter methods for isActive should be getIsActive and setIsActive without underscore 您对isActive的getter和setter方法应为getIsActive和setIsActive,且不带下划线
public Integer getIsActive() {
return isActive;
}
public void setIsActive(Integer is_active) {
this.isActive = is_active;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.