Spring Cloud OpenFeign 默认使用的是 JDK 自带的 HttpURLConnection,不是 Apache HttpClient。要使用 HttpClient5,需要进行额外配置。
首先,需要添加 HttpClient5 的依赖:
然后,在配置文件中指定 Feign 使用 HttpClient5:
这样就可以在 Spring Cloud OpenFeign 中使用 HttpClient5 作为 HTTP 客户端了。注意替换 版本号
为你使用的 Spring Cloud 版本对应的 HttpClient5 Feign 版本。