2016-10-04 1 views
0

deserialisieren kann ich versuche Objekt in der Datenbank einzufügen, aber ich bin immer diese FehlermeldungJsonMappingException nicht Instanz von 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"]) 

mein Code:

@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 ist Skalar sein, versuchen, den „String“ zu bekommen Wert für json. Überprüfen Sie diesen Thread https://github.com/FasterXML/jackson-dataformat-xml/issues/139 –

Antwort

0

Ich glaube, Ihr JSON für isActive ist von boolean isActive : true Es erwartet, dass der Typ boolean nicht ganzzahlig ist. Dies ist macht Ihren Jackson

Ihre private Integer isActive;-private boolean isActive;

+0

danke, es behebt das Problem –

0

Ihr Getter und Setter-Methoden für isActive ändern sollte getIsActive und setIsActive ohne Unterstrich

public Integer getIsActive() { 
     return isActive; 
} 

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