Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JsonMappingException无法反序列化java.lang.Integer的实例_Java_Spring - Fatal编程技术网

JsonMappingException无法反序列化java.lang.Integer的实例

JsonMappingException无法反序列化java.lang.Integer的实例,java,spring,Java,Spring,我试图在我的数据库中插入对象,但出现了此错误 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.PushbackIn

我试图在我的数据库中插入对象,但出现了此错误

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"])
我的代码是:

@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;
    }

我相信您的isActive JSON是布尔值
isActive:true
它应为布尔类型,而不是整数类型。 这是你的杰克逊


将您的
私有整数更改为活动
私有布尔值为活动

我相信您的isActive JSON是布尔值
isActive:true
它应为布尔类型,而不是整数类型。 这是你的杰克逊


将您的
私有整数更改为活动
私有布尔值为活动

isActive的getter和setter方法应为getIsActive和setIsActive,且不带下划线

public Integer getIsActive() {
        return isActive;
}

public void setIsActive(Integer is_active) {
        this.isActive = is_active;
}

isActive的getter和setter方法应为getIsActive和setIsActive,且不带下划线

public Integer getIsActive() {
        return isActive;
}

public void setIsActive(Integer is_active) {
        this.isActive = is_active;
}

如果您正试图测试API,请抛出postman,并且如果您只有integer类型的on输入,则应该将其直接发送到body,而不使用json对象大括号

查看下面的图片了解更多详细信息


如果您试图测试API,则会抛出postman,如果您只有integer类型的on输入,则应将其直接发送到body,而不使用json对象括号

查看下面的图片了解更多详细信息


整数是标量,请尝试获取json的“字符串”值。检查此线程整数是否为标量,尝试获取json的“字符串”值。检查这条线