先说需求,服务间的调用需要查询数据,但是需要传递一个list数组,写get请求,后台报错却是找不到post请求。
报异常
Request method ‘POST’ not supported
解决:
1.参数添加@RequestBody 注解。
2.在调用端添加依赖
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>9.5.0</version>
</dependency>
yml配置文件:
feign:
httpclient:
enabled: true
这样就可以解决,feign的get传递参数问题。
没有为什么,这就是解决方案。
原理:因为Feign默认使用的连接工具实现类,所以里面发现只要你有body体对象,就会强制的把get请求转换成POST请求