spring cloud——Feign爲GET請求時的多個對象參數傳遞--問題解決

在?解bug,挺急的。

1. 添加依賴

不使用maven的大佬,自己去找下其他的吧。
依賴查找

 <!-- https://mvnrepository.com/artifact/io.github.openfeign/feign-httpclient -->
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-httpclient</artifactId>
            <version>10.4.0</version>
        </dependency>

2. 添加描述。

在Feign接口上的方法的@RequstMapping或是@GetMapping註解加上 consumes = MediaType.APPLICATION_JSON_UTF8_VALUE。
示例:

/**
 * @author: san
 * @date: 2020/6/12
 * @description: 
 * @version: 1.0
 */
@FeignClient(name = "m-service", path = "/test", fallbackFactory = m.class)
public interface test{
    @GetMapping(consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Response<SimplePageImpl<mDTO>> getMarketerByPage(Pageable pageable);
}

3.傳遞多個對象,加@SpringQueryMap註解

/**
 * @author: san
 * @date: 2020/6/12
 * @description: 
 * @version: 1.0
 */
@FeignClient(name = "m-service", path = "/test", fallbackFactory = m.class)
public interface test{
    @GetMapping(consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Response<SimplePageImpl<mDTO>> getMByPage(@SpringQueryMap Pageable pageable, MQueryRequest mQueryRequest);

}

4.總結說明

全程改動只需改Feign層代碼即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章