情况说明:
在feign调用服务的时候query参数对象需要使用@SpringQueryMap注解,此注解只对第一个参数有效。
处理feign对pageable的解析:
/**
* @author Lee
* @description 配置feign 解析pageable
* @date 2020/10/29 7:32 下午
**/
@Bean
public com.fasterxml.jackson.databind.Module pageJacksonModule() {
return new PageJacksonModule();
}
目前出现的问题是:
在使用springcloud Hoxton.SR2 (feign.core 10.4.0)以上版本时 由于feign对query参数,的处理导致pageable的排序无法正常使用。
在使用springcloud Hoxton.SR2 (feign.core 10.4.0) 时pageable正常,但是发现有的程序员对pageable也使用了@SpringQueryMap,导致出现 No properties id:DESC found on type ,根据排查发现原本应解析成 id: DESC 的pageable sort 解析成了id:DESC:DESC.
解决办法:
在feign传递pageable 参数时,pageable前面不要使用@SpringQueryMap注解。
feignClient正确写法:
多个参数:
单个参数: