2016-10-04 5 views
0

Я пытаюсь вставить объект в моей базе данных, но я получаю эту ошибкуJsonMappingException не десериализация экземпляра java.lang.Integer

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: [email protected]; 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: [email protected]; 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; 
    } 
+0

Integar является скаляром, попытаться получить «String» значение для json. Проверьте эту тему https://github.com/FasterXML/jackson-dataformat-xml/issues/139 –

ответ

0

Я считаю, что ваш JSON для isActive имеет значение boolean isActive : true Ожидается, что он будет иметь тип boolean not integer. Это делает ваш Джексон

Меняйте private Integer isActive; в private boolean isActive;

+0

спасибо, это исправить проблему –

0

Ваши методы получения и установки для IsActive должны быть getIsActive и setIsActive без подчеркивания

public Integer getIsActive() { 
     return isActive; 
} 

public void setIsActive(Integer is_active) { 
     this.isActive = is_active; 
} 
Смежные вопросы