假设客户端:在Map <string,object =“”>中解码为Integer

时间:2017-06-06 16:56:25

标签: java gson feign

public interface ItemsClient {
    @RequestLine("POST /items")
    public Map<String, Object> post(Map<String, Object> item);
}

然后

ItemsClient itemsClient = Feign.builder().decoder(new GsonDecoder()).encoder(new GsonEncoder()).target(ItemsClient.class, ROOT_URI);
Map<String, Object> myNewItemWithId = itemsClient.post(myNewItem);

服务器发送一个响应,其身体如下:

{
    "id" : 108171343002018,
    "name" : "myNewItem among many and many !"
}

但是myNewItemWithId.get(“id”)的值;是2147483647,Integer的最大值。

有没有办法告诉GsonDecoder将整数解码为Long?

1 个答案:

答案 0 :(得分:0)

它适用于JacksonDecoder。

<dependency>
    <groupId>io.github.openfeign</groupId>
    <artifactId>feign-jackson</artifactId>
    <version>9.0.0</version>
</dependency>