@JsonProperty not working as expected

后端 未结 1 844
不思量自难忘°
不思量自难忘° 2021-01-06 18:43

I get the following exception when i consume a restful webservice using Spring RestTemplate

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:         


        
相关标签:
1条回答
  • 2021-01-06 19:23

    There are many implementations of "REST API" and they conflict with each other. After a lot of time, I resolved it with this configuration:

    import com.fasterxml.jackson.annotation.JsonProperty;
    ...
    @JsonProperty("cep")
    private String cep;
    

    Must have that JsonProperty with this package not org.codehaus...

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19</version>
        <scope>test</scope>
    </dependency>
    

    In summary: jersey client 1, jackson json property and remove all others jaxrc libs.

    Obs:. I used jackson because the container already provided, but, if it works for you, you could test another combinations.

    0 讨论(0)
提交回复
热议问题