目录
服务提供者:
?
/**
* 获取用户ID
* @param token
* @return
*/
@GetMapping("/getUserId")
public String getUserId(@RequestParam(required = false) String token){
return userService.getUserId(token);
}
服务调用
@Service
@FeignClient(value = "auth-service")
public interface AuthClient {
/**
* 获取用户ID
* @param token
* @return
*/
@GetMapping("/user/getUserId")
public String getUserId(@RequestParam(required = false) String token);
}
会自动讲get请求转为post请求
因为Feign默认使用的连接工具实现类,所以里面发现只要你有body体对象,就会强制的把GET请求转换成POST请求。
更换Apache的HttpClient
feign:
httpclient:
enabled: true
<!-- httpclient5 -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<!-- feign-httpclient -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
?
?