{"id":96630,"date":"2026-08-28T03:32:36","date_gmt":"2026-08-27T19:32:36","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/96630.html"},"modified":"2026-08-28T03:32:36","modified_gmt":"2026-08-27T19:32:36","slug":"spring-cloud%ef%bc%9a%e5%88%86%e5%b8%83%e5%bc%8f%e7%b3%bb%e7%bb%9f%e7%9a%84%e7%b2%98%e5%90%88%e5%89%82%ef%bc%88%e4%b8%83%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/96630.html","title":{"rendered":"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09"},"content":{"rendered":"<p class=\"img-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193233-6a9090d1f0697.gif\" \/><\/p>\n<p class=\"img-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193234-6a9090d21b206.jpg\" \/><\/p>\n<p class=\"img-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193234-6a9090d25d7c6.gif\" \/><\/p>\n<p style=\"text-align:center\"><span style=\"color:#fe2c24\">\u4e13\u680f&#xff1a;Spring Cloud<\/span><\/p>\n<p style=\"text-align:center\"><span style=\"color:#fe2c24\">\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u624b\u63e1\u98ce\u4e91<\/span><\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81RestTemplate%20%E7%9A%84%E9%97%AE%E9%A2%98-toc\" style=\"margin-left:0px\">\u4e00\u3001RestTemplate \u7684\u95ee\u9898<\/p>\n<p id=\"%E4%BA%8C%E3%80%81OpenFeign%20%E4%BB%8B%E7%BB%8D-toc\" style=\"margin-left:0px\">\u4e8c\u3001OpenFeign \u4ecb\u7ecd<\/p>\n<p id=\"%E4%B8%89%E3%80%81OpenFeign%20%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B-toc\" style=\"margin-left:0px\">\u4e09\u3001OpenFeign \u5feb\u901f\u4e0a\u624b<\/p>\n<p id=\"3.1.%C2%A0%E5%BC%95%E5%85%A5%E4%BE%9D%E8%B5%96-toc\" style=\"margin-left:40px\">3.1.\u00a0\u5f15\u5165\u4f9d\u8d56<\/p>\n<p id=\"3.2.%C2%A0%E5%BC%80%E5%90%AF%E5%8A%9F%E8%83%BD-toc\" style=\"margin-left:40px\">3.2.\u00a0\u5f00\u542f\u529f\u80fd<\/p>\n<p id=\"3.3.%C2%A0%E7%BC%96%E5%86%99%20Feign%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%8F%A3-toc\" style=\"margin-left:40px\">3.3.\u00a0\u7f16\u5199 Feign \u5ba2\u6237\u7aef\u63a5\u53e3<\/p>\n<p id=\"3.4.%C2%A0%E8%B0%83%E7%94%A8%E8%BF%9C%E7%A8%8B%E6%8E%A5%E5%8F%A3-toc\" style=\"margin-left:40px\">3.4.\u00a0\u8c03\u7528\u8fdc\u7a0b\u63a5\u53e3<\/p>\n<p id=\"%E5%9B%9B%E3%80%81OpenFeign%20%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92-toc\" style=\"margin-left:0px\">\u56db\u3001OpenFeign \u53c2\u6570\u4f20\u9012<\/p>\n<p id=\"4.1.%C2%A0%E5%8D%95%E4%B8%AA%E6%99%AE%E9%80%9A%E5%8F%82%E6%95%B0%EF%BC%88Query%20%E5%8F%82%E6%95%B0%EF%BC%89-toc\" style=\"margin-left:40px\">4.1.\u00a0\u5355\u4e2a\u666e\u901a\u53c2\u6570&#xff08;Query \u53c2\u6570&#xff09;<\/p>\n<p id=\"4.2.%C2%A0%E5%A4%9A%E4%B8%AA%E6%99%AE%E9%80%9A%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:40px\">4.2.\u00a0\u591a\u4e2a\u666e\u901a\u53c2\u6570<\/p>\n<p id=\"4.3.%C2%A0%E5%AF%B9%E8%B1%A1%E4%BD%9C%E4%B8%BA%20Query%20%E5%8F%82%E6%95%B0%E6%8B%BC%E6%8E%A5-toc\" style=\"margin-left:40px\">4.3.\u00a0\u5bf9\u8c61\u4f5c\u4e3a Query \u53c2\u6570\u62fc\u63a5<\/p>\n<p id=\"4.4.%C2%A0%E4%BC%A0%E9%80%92%20JSON%20%E8%AF%B7%E6%B1%82%E4%BD%93-toc\" style=\"margin-left:40px\">4.4.\u00a0\u4f20\u9012 JSON \u8bf7\u6c42\u4f53<\/p>\n<p id=\"%E4%BA%94%E3%80%81%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5-toc\" style=\"margin-left:0px\">\u4e94\u3001\u6700\u4f73\u5b9e\u8df5<\/p>\n<p id=\"5.1.%C2%A0Feign%20%E7%BB%A7%E6%89%BF%E6%96%B9%E5%BC%8F-toc\" style=\"margin-left:40px\">5.1.\u00a0Feign \u7ee7\u627f\u65b9\u5f0f<\/p>\n<p id=\"5.2.%C2%A0Feign%20%E6%8A%BD%E5%8F%96%E7%8B%AC%E7%AB%8B%E6%A8%A1%E5%9D%97-toc\" style=\"margin-left:40px\">5.2.\u00a0Feign \u62bd\u53d6\u72ec\u7acb\u6a21\u5757<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 style=\"background-color:transparent\">\u4e00\u3001RestTemplate \u7684\u95ee\u9898<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u524d\u9762\u7684\u9879\u76ee\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528RestTemplate\u5b8c\u6210\u5fae\u670d\u52a1\u4e4b\u95f4\u7684HTTP\u8fdc\u7a0b\u8c03\u7528\u3002\u4ece\u793a\u4f8b\u4ee3\u7801\u80fd\u591f\u770b\u5230&#xff0c;\u8c03\u7528\u65b9\u901a\u8fc7\u62fc\u63a5\u76ee\u6807\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740&#xff0c;\u518d\u501f\u52a9 getForObject \u65b9\u6cd5\u53d1\u8d77 http \u8bf7\u6c42&#xff0c;\u62ff\u5230\u8fdc\u7aef\u8fd4\u56de\u7684\u6570\u636e&#xff0c;\u5b8c\u6210\u4e1a\u52a1\u903b\u8f91\u7ec4\u88c5\u3002<\/p>\n<p>public OrderInfo selectOrderById(Integer orderId) {<br \/>\n    OrderInfo orderInfo &#061; orderMapper.selectOrderById(orderId);<br \/>\n    String url &#061; &#034;http:\/\/product-service\/product\/&#034; &#043; orderInfo.getProductId();<br \/>\n    ProductInfo productInfo &#061; restTemplate.getForObject(url, ProductInfo.class);<br \/>\n    orderInfo.setProductInfo(productInfo);<br \/>\n    return orderInfo;<br \/>\n} <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u867d\u7136 RestTemplate \u5df2\u7ecf\u5bf9\u5e95\u5c42 HTTP \u8bf7\u6c42\u505a\u4e86\u5c01\u88c5&#xff0c;\u5bf9\u6bd4\u539f\u751f HTTPClient&#xff0c;\u4f7f\u7528\u4e0a\u5df2\u7ecf\u7b80\u5316\u4e0d\u5c11&#xff0c;\u4f46\u662f\u5b83\u4f9d\u65e7\u5b58\u5728\u660e\u663e\u7684\u7f3a\u9677\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b2c\u4e00\u4e2a\u95ee\u9898\u662f\u9700\u8981\u624b\u52a8\u62fc\u63a5 URL \u5730\u5740\u3002\u8fd9\u79cd\u65b9\u5f0f\u867d\u7136\u7075\u6d3b&#xff0c;\u4f46\u662f\u4ee3\u7801\u5c01\u88c5\u6bd4\u8f83\u81c3\u80bf\u3002\u5f53\u8bf7\u6c42\u53c2\u6570\u8f83\u591a\u3001URL \u903b\u8f91\u590d\u6742\u7684\u65f6\u5019&#xff0c;\u624b\u52a8\u62fc\u63a5\u5b57\u7b26\u4e32\u5f88\u5bb9\u6613\u51fa\u73b0\u4e66\u5199\u9519\u8bef&#xff0c;\u5f15\u53d1\u8c03\u7528\u5f02\u5e38\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b2c\u4e8c\u4e2a\u95ee\u9898\u662f\u4ee3\u7801\u53ef\u8bfb\u6027\u5dee\u3001\u7f16\u7801\u98ce\u683c\u4e0d\u7edf\u4e00\u3002\u8fdc\u7a0b\u8c03\u7528\u7684 http \u8bf7\u6c42\u903b\u8f91\u76f4\u63a5\u5199\u5728\u4e1a\u52a1\u65b9\u6cd5\u5185\u90e8&#xff0c;URL\u5b57\u7b26\u4e32\u3001\u8fd4\u56de\u503c\u7c7b\u578b\u786c\u7f16\u7801\u5728\u4ee3\u7801\u4e2d&#xff0c;\u548c\u666e\u901a\u672c\u5730\u65b9\u6cd5\u8c03\u7528\u5199\u6cd5\u5dee\u5f02\u5f88\u5927&#xff0c;\u9605\u8bfb\u548c\u7ef4\u62a4\u8d77\u6765\u4e0d\u591f\u76f4\u89c2\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5fae\u670d\u52a1\u4e3b\u6d41\u7684\u901a\u4fe1\u65b9\u5f0f\u5206\u4e3a\u4e24\u79cd&#xff0c;\u5206\u522b\u662f HTTP \u901a\u4fe1\u4e0e RPC \u901a\u4fe1\u3002Spring Cloud \u6846\u67b6\u9ed8\u8ba4\u91c7\u7528HTTP \u5b9e\u73b0\u5fae\u670d\u52a1\u901a\u4fe1&#xff0c;\u5e38\u7528\u5b9e\u73b0\u65b9\u6848\u5305\u542b RestTemplate \u4e0e OpenFeign\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0RPC \u5168\u79f0\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528&#xff0c;\u6838\u5fc3\u601d\u60f3\u662f\u53ef\u4ee5\u50cf\u8c03\u7528\u672c\u5730\u65b9\u6cd5\u4e00\u6837\u8c03\u7528\u8fdc\u7a0b\u670d\u52a1&#xff0c;\u4f7f\u7528\u8005\u4e0d\u9700\u8981\u5173\u5fc3\u5e95\u5c42\u7f51\u7edc\u901a\u4fe1\u7684\u5177\u4f53\u5b9e\u73b0\u7ec6\u8282\u3002RPC \u5e76\u4e0d\u9650\u5b9a\u5e95\u5c42\u534f\u8bae&#xff0c;\u53ef\u4ee5\u4f7f\u7528 HTTP\u3001TCP\u3001UDP \u7b49\u591a\u79cd\u534f\u8bae&#xff0c;\u5728TCP\/IP\u56db\u5c42\u6a21\u578b\u4e2d\u540c\u65f6\u8de8\u8d8a\u4f20\u8f93\u5c42\u4e0e\u5e94\u7528\u5c42\u3002\u4e1a\u754c\u5e38\u89c1\u7684RPC\u6846\u67b6\u6709 Dubbo\u3001Thrift\u3001gRPC\u3002<\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81OpenFeign%20%E4%BB%8B%E7%BB%8D\" style=\"background-color:transparent\">\u4e8c\u3001OpenFeign \u4ecb\u7ecd<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OpenFeign \u662f\u4e00\u6b3e\u58f0\u660e\u5f0f\u7684 Web Service \u5ba2\u6237\u7aef&#xff0c;\u5b83\u80fd\u591f\u7b80\u5316\u5fae\u670d\u52a1\u4e4b\u95f4\u7684\u8fdc\u7a0b\u8c03\u7528\u3002\u4f7f\u7528OpenFeign \u53d1\u8d77\u8c03\u7528\u7684\u4f53\u9a8c&#xff0c;\u7c7b\u4f3c\u4e8e Controller \u8c03\u7528 Service&#xff0c;\u5f00\u53d1\u8005\u53ea\u9700\u8981\u5b9a\u4e49\u63a5\u53e3&#xff0c;\u5e76\u5728\u63a5\u53e3\u4e0a\u6dfb\u52a0\u5bf9\u5e94\u7684\u6ce8\u89e3&#xff0c;\u5c31\u53ef\u4ee5\u5b8c\u6210\u8fdc\u7a0b\u8c03\u7528\u7684\u5168\u90e8\u914d\u7f6e\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OpenFeign\u7684\u524d\u8eab\u662fNetflix\u516c\u53f8\u5f00\u6e90\u7684Feign\u7ec4\u4ef6\u30022013\u5e746\u6708Netflix\u53d1\u5e03\u4e86Feign\u7684\u7b2c\u4e00\u4e2a\u7248\u672c1.0.0&#xff1b;2016\u5e747\u6708&#xff0c;Netflix\u53d1\u5e03Feign\u6700\u540e\u4e00\u4e2a\u7248\u672c8.18.0&#xff0c;\u4e4b\u540eNetflix\u5c06Feign\u6350\u8d60\u7ed9\u5f00\u6e90\u793e\u533a\u3002\u540c\u5e747\u6708&#xff0c;OpenFeign\u53d1\u5e03\u9996\u4e2a\u7248\u672c9.0.0&#xff0c;\u6b64\u540e\u4e00\u76f4\u7531\u793e\u533a\u6301\u7eed\u7ef4\u62a4\u66f4\u65b0\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b80\u5355\u6765\u8bf4&#xff0c;Netflix Feign\u5c31\u662fOpenFeign\u7684\u524d\u8eab&#xff0c;OpenFeign\u662f\u5728\u539f\u6709Feign\u57fa\u7840\u4e4b\u4e0a\u5347\u7ea7\u800c\u6765&#xff0c;\u529f\u80fd\u66f4\u5f3a\u5927\u3001\u4f7f\u7528\u4e5f\u66f4\u52a0\u7075\u6d3b\u3002\u73b0\u5728\u7f51\u7edc\u5404\u7c7b\u6280\u672f\u6587\u7ae0&#xff0c;\u4ee5\u53ca\u4f01\u4e1a\u9879\u76ee\u4e2d\u4f7f\u7528\u7684Feign&#xff0c;\u57fa\u672c\u90fd\u662fOpenFeign\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Spring Cloud Feign \u662f Spring \u6846\u67b6\u5bf9 Feign \u505a\u7684\u4e00\u5c42\u5c01\u88c5&#xff0c;\u76ee\u7684\u662f\u628a Feign \u96c6\u6210\u8fdb Spring Cloud\u5b8c\u6574\u751f\u6001\u3002\u56e0\u4e3aFeign\u9879\u76ee\u66f4\u540d&#xff0c;Spring Cloud\u4e5f\u63d0\u4f9b\u4e86\u4e24\u5957\u4e0d\u540c\u7684starter\u4f9d\u8d56\u3002\u65e7\u7248\u672c\u4e3aspring\u2011cloud\u2011starter\u2011feign&#xff0c;\u65b0\u7248\u672c\u4e3a spring\u2011cloud\u2011starter\u2011openfeign\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7531\u4e8e\u539f\u59cb\u7684Netflix Feign\u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4&#xff0c;\u6211\u4eec\u5b9e\u9645\u5f00\u53d1\u9879\u76ee\u4e2d&#xff0c;\u8981\u9009\u7528\u00a0spring\u2011cloud\u2011starter\u2011openfeign \u8fd9\u4e2a\u4f9d\u8d56\u3002\u5982\u679c\u9700\u8981\u67e5\u9605\u5b98\u65b9\u8d44\u6599&#xff0c;\u53ef\u4ee5\u53c2\u8003 OpenFeign \u7684GitHub\u6587\u6863&#xff0c;\u4ee5\u53ca Spring Cloud OpenFeign\u7684\u5b98\u65b9\u6587\u6863\u3002<\/p>\n<p>OpenFeign \u5b98\u65b9\u6587\u6863&#xff1a;https:\/\/github.com\/openfeign\/feign<\/p>\n<p>Spring Cloud Feign \u6587\u6863&#xff1a;Spring Cloud OpenFeign<\/p>\n<h2 id=\"%E4%B8%89%E3%80%81OpenFeign%20%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B\">\u4e09\u3001OpenFeign \u5feb\u901f\u4e0a\u624b<\/h2>\n<h3 id=\"3.1.%C2%A0%E5%BC%95%E5%85%A5%E4%BE%9D%E8%B5%96\">3.1.\u00a0\u5f15\u5165\u4f9d\u8d56<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5bfc\u5165 spring\u2011cloud\u2011starter\u2011openfeign<\/p>\n<p>&lt;dependency&gt;<br \/>\n&lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;<br \/>\n&lt;artifactId&gt;spring-cloud-starter-openfeign&lt;\/artifactId&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<h3 id=\"3.2.%C2%A0%E5%BC%80%E5%90%AF%E5%8A%9F%E8%83%BD\">3.2.\u00a0\u5f00\u542f\u529f\u80fd<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u542f\u52a8\u7c7b\u589e\u52a0\u6ce8\u89e3 &#064;EnableFeignClients \u5f00\u542f Feign\u3002<\/p>\n<p>package com.yang.order;<\/p>\n<p>import org.springframework.boot.SpringApplication;<br \/>\nimport org.springframework.boot.autoconfigure.SpringBootApplication;<br \/>\nimport org.springframework.cloud.openfeign.EnableFeignClients;<\/p>\n<p>&#064;EnableFeignClients<br \/>\n&#064;SpringBootApplication<br \/>\npublic class OrderServiceApplication {<br \/>\n    public static void main(String[] args) {<br \/>\n        SpringApplication.run(OrderServiceApplication.class, args);<br \/>\n    }<br \/>\n} <\/p>\n<h3 id=\"3.3.%C2%A0%E7%BC%96%E5%86%99%20Feign%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%8F%A3\">3.3.\u00a0\u7f16\u5199 Feign \u5ba2\u6237\u7aef\u63a5\u53e3<\/h3>\n<ul>\n<li>&#064;FeignClient \u6ce8\u89e3\u4fee\u9970\u63a5\u53e3&#xff1b;<\/li>\n<li>value\/name \u6307\u5b9a\u76ee\u6807\u5fae\u670d\u52a1\u540d\u79f0&#xff0c;\u7528\u4e8e Nacos \u670d\u52a1\u53d1\u73b0&#xff0c;\u5e95\u5c42\u81ea\u52a8\u8d1f\u8f7d\u5747\u8861&#xff1b;path \u7edf\u4e00\u8bbe\u7f6e\u8bf7\u6c42\u8def\u5f84\u524d\u7f00&#xff1b;<\/li>\n<li>\u63a5\u53e3\u65b9\u6cd5\u76f4\u63a5\u4f7f\u7528 SpringMVC \u6ce8\u89e3\u5b9a\u4e49\u8bf7\u6c42\u8def\u5f84\u3001\u53c2\u6570&#xff1b;<\/li>\n<\/ul>\n<p>package com.yang.order.api;<\/p>\n<p>import com.yang.order.model.ProductInfo;<br \/>\nimport org.springframework.cloud.openfeign.FeignClient;<br \/>\nimport org.springframework.web.bind.annotation.PathVariable;<br \/>\nimport org.springframework.web.bind.annotation.RequestMapping;<\/p>\n<p>&#064;FeignClient(value &#061; &#034;product-service&#034;, path &#061; &#034;\/product&#034;)<br \/>\npublic interface ProductApi {<br \/>\n    &#064;RequestMapping(&#034;\/{productId}&#034;)<br \/>\n    ProductInfo getProductInfo(&#064;PathVariable(&#034;productId&#034;) Integer productId);<br \/>\n} <\/p>\n<h3 id=\"3.4.%C2%A0%E8%B0%83%E7%94%A8%E8%BF%9C%E7%A8%8B%E6%8E%A5%E5%8F%A3\">3.4.\u00a0\u8c03\u7528\u8fdc\u7a0b\u63a5\u53e3<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u76f4\u63a5 &#064;Autowired \u6ce8\u5165 Feign \u63a5\u53e3&#xff0c;\u50cf\u8c03\u7528\u672c\u5730\u65b9\u6cd5\u4e00\u6837\u8c03\u7528\u63a5\u53e3\u65b9\u6cd5&#xff0c;\u5b8c\u6210\u8fdc\u7a0b http \u8c03\u7528\u3002<\/p>\n<p>package com.yang.order.service;<\/p>\n<p>import com.yang.order.api.ProductApi;<br \/>\nimport com.yang.order.mapper.OrderMapper;<br \/>\nimport com.yang.order.model.OrderInfo;<br \/>\nimport com.yang.order.model.ProductInfo;<br \/>\nimport org.springframework.beans.factory.annotation.Autowired;<br \/>\nimport org.springframework.stereotype.Service;<br \/>\nimport org.springframework.web.client.RestTemplate;<\/p>\n<p>&#064;Service<br \/>\npublic class OrderService {<br \/>\n    &#064;Autowired<br \/>\n    private OrderMapper orderMapper;<br \/>\n    &#064;Autowired<br \/>\n    private RestTemplate restTemplate;<br \/>\n    &#064;Autowired<br \/>\n    private ProductApi productApi;<\/p>\n<p>    public OrderInfo selectOrderById(Integer orderId) {<br \/>\n        OrderInfo orderInfo &#061; orderMapper.selectOrderById(orderId);<br \/>\n        \/*String url &#061; &#034;http:\/\/product-service\/product\/&#034; &#043; orderInfo.getProductId();<br \/>\n        ProductInfo productInfo &#061; restTemplate.getForObject(url, ProductInfo.class);*\/<\/p>\n<p>        ProductInfo productInfo &#061; productApi.getProductInfo(orderInfo.getProductId());<br \/>\n        orderInfo.setProductInfo(productInfo);<br \/>\n        return orderInfo;<br \/>\n    }<br \/>\n} <\/p>\n<h2 id=\"%E5%9B%9B%E3%80%81OpenFeign%20%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92\">\u56db\u3001OpenFeign \u53c2\u6570\u4f20\u9012<\/h2>\n<h3 id=\"4.1.%C2%A0%E5%8D%95%E4%B8%AA%E6%99%AE%E9%80%9A%E5%8F%82%E6%95%B0%EF%BC%88Query%20%E5%8F%82%E6%95%B0%EF%BC%89\">4.1.\u00a0\u5355\u4e2a\u666e\u901a\u53c2\u6570&#xff08;Query \u53c2\u6570&#xff09;<\/h3>\n<p>package com.yang.product.controller;<\/p>\n<p>import com.yang.product.model.ProductInfo;<br \/>\nimport com.yang.product.service.ProductService;<br \/>\nimport org.springframework.beans.factory.annotation.Autowired;<br \/>\nimport org.springframework.web.bind.annotation.*;<\/p>\n<p>&#064;RestController<br \/>\n&#064;RequestMapping(&#034;\/product&#034;)<br \/>\npublic class ProductController {<br \/>\n    &#064;RequestMapping(&#034;\/p1&#034;)<br \/>\n    public String p1(Integer id) {<br \/>\n        return &#034;product-service \u63a5\u6536\u5230\u53c2\u6570, id:&#034; &#043; id;<br \/>\n    }<br \/>\n}<br \/>\npackage com.yang.order.api;<\/p>\n<p>import org.springframework.cloud.openfeign.FeignClient;<br \/>\nimport org.springframework.web.bind.annotation.RequestMapping;<br \/>\nimport org.springframework.web.bind.annotation.RequestParam;<\/p>\n<p>&#064;FeignClient(value &#061; &#034;product-service&#034;, path &#061; &#034;\/product&#034;)<br \/>\npublic interface ProductApi {<br \/>\n    &#064;RequestMapping(&#034;\/p1&#034;)<br \/>\n    public String p1(&#064;RequestParam(&#034;id&#034;) Integer id);<br \/>\n}<br \/>\npackage com.yang.order.controller;<\/p>\n<p>import com.yang.order.api.ProductApi;<br \/>\nimport com.yang.order.model.ProductInfo;<br \/>\nimport org.springframework.beans.factory.annotation.Autowired;<br \/>\nimport org.springframework.web.bind.annotation.RequestMapping;<br \/>\nimport org.springframework.web.bind.annotation.RestController;<\/p>\n<p>&#064;RestController<br \/>\n&#064;RequestMapping(&#034;\/feign&#034;)<br \/>\npublic class FeignController {<br \/>\n    &#064;Autowired<br \/>\n    private ProductApi productApi;<\/p>\n<p>    &#064;RequestMapping(&#034;\/o1&#034;)<br \/>\n    public String o1(Integer id) {<br \/>\n        return productApi.p1(id);<br \/>\n    }<br \/>\n} <\/p>\n<h3 id=\"4.2.%C2%A0%E5%A4%9A%E4%B8%AA%E6%99%AE%E9%80%9A%E5%8F%82%E6%95%B0\">4.2.\u00a0\u591a\u4e2a\u666e\u901a\u53c2\u6570<\/h3>\n<p>&#064;RequestMapping(&#034;\/p2&#034;)<br \/>\npublic String p2(Integer id, String name) {<br \/>\n    return &#034;product-service \u63a5\u6536\u5230\u53c2\u6570, id:&#034; &#043; id &#043; &#034;, name:&#034; &#043; name;<br \/>\n}<br \/>\n&#064;RequestMapping(&#034;\/p2&#034;)<br \/>\npublic String p2(&#064;RequestParam(&#034;id&#034;) Integer id, &#064;RequestParam(&#034;name&#034;) String name);<br \/>\n&#064;RequestMapping(&#034;\/o2&#034;)<br \/>\npublic String o2(Integer id, String name) {<br \/>\n    return productApi.p2(id, name);<br \/>\n} <\/p>\n<h3 id=\"4.3.%C2%A0%E5%AF%B9%E8%B1%A1%E4%BD%9C%E4%B8%BA%20Query%20%E5%8F%82%E6%95%B0%E6%8B%BC%E6%8E%A5\">4.3.\u00a0\u5bf9\u8c61\u4f5c\u4e3a Query \u53c2\u6570\u62fc\u63a5<\/h3>\n<p>&#064;RequestMapping(&#034;\/p3&#034;)<br \/>\npublic String p3(ProductInfo productInfo) {<br \/>\n    return &#034;product-service \u63a5\u6536\u5230\u53c2\u6570: productInfo&#034; &#043; productInfo.toString();<br \/>\n}<br \/>\n&#064;RequestMapping(&#034;\/p3&#034;)<br \/>\npublic String p3(&#064;SpringQueryMap ProductInfo productInfo);<br \/>\n&#064;RequestMapping(&#034;\/o3&#034;)<br \/>\npublic String o3(ProductInfo productInfo) {<br \/>\n    productInfo.setId(45);<br \/>\n    productInfo.setProductName(&#034;T\u6064&#034;);<br \/>\n    return productApi.p3(productInfo);<br \/>\n} <\/p>\n<h3 id=\"4.4.%C2%A0%E4%BC%A0%E9%80%92%20JSON%20%E8%AF%B7%E6%B1%82%E4%BD%93\">4.4.\u00a0\u4f20\u9012 JSON \u8bf7\u6c42\u4f53<\/h3>\n<p>&#064;RequestMapping(&#034;\/p4&#034;)<br \/>\npublic String p4(&#064;RequestBody ProductInfo productInfo) {<br \/>\n    return &#034;product-service \u63a5\u6536\u5230\u53c2\u6570: productInfo &#034; &#043; productInfo.toString();<br \/>\n}<br \/>\n&#064;RequestMapping(&#034;\/p4&#034;)<br \/>\npublic String p4(&#064;RequestBody ProductInfo productInfo);<br \/>\n&#064;RequestMapping(&#034;\/o4&#034;)<br \/>\npublic String o4(ProductInfo productInfo) {<br \/>\n    productInfo.setId(46);<br \/>\n    productInfo.setProductName(&#034;T\u6064&#034;);<br \/>\n    return productApi.p4(productInfo);<br \/>\n} <\/p>\n<h2 id=\"%E4%BA%94%E3%80%81%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5\">\u4e94\u3001\u6700\u4f73\u5b9e\u8df5<\/h2>\n<h3 id=\"5.1.%C2%A0Feign%20%E7%BB%A7%E6%89%BF%E6%96%B9%E5%BC%8F\">5.1.\u00a0Feign \u7ee7\u627f\u65b9\u5f0f<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Feign \u652f\u6301\u7ee7\u627f\u7684\u5f00\u53d1\u6a21\u5f0f&#xff0c;\u6211\u4eec\u53ef\u4ee5\u628a\u516c\u5171\u7684\u63a5\u53e3\u64cd\u4f5c\u5c01\u88c5\u5230\u5355\u72ec\u7684\u63a5\u53e3\u5f53\u4e2d\u3002\u5177\u4f53\u601d\u8def\u4e3a&#xff1a;\u9884\u5148\u5b9a\u4e49\u516c\u5171\u63a5\u53e3&#xff0c;\u7531\u670d\u52a1\u63d0\u4f9b\u65b9\u7684 Controller \u53bb\u5b9e\u73b0\u8fd9\u4e2a\u63a5\u53e3&#xff1b;\u800c\u670d\u52a1\u6d88\u8d39\u65b9\u7f16\u5199 Feign \u5ba2\u6237\u7aef\u63a5\u53e3\u65f6&#xff0c;\u76f4\u63a5\u7ee7\u627f\u8be5\u516c\u5171\u63a5\u53e3\u5373\u53ef\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"756\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193234-6a9090d26fe18.png\" width=\"1188\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9996\u5148\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684 Module \u6a21\u5757&#xff0c;\u8fd9\u4e2a\u6a21\u5757\u7528\u4e8e\u5b58\u653e\u516c\u5171\u63a5\u53e3&#xff0c;\u6253\u5305\u751f\u6210 Jar \u5305\u4e4b\u540e&#xff0c;\u53ef\u4ee5\u540c\u65f6\u7ed9\u670d\u52a1\u63d0\u4f9b\u65b9\u548c\u670d\u52a1\u6d88\u8d39\u65b9\u5171\u540c\u4f9d\u8d56\u4f7f\u7528\u3002\u521b\u5efa\u6a21\u5757\u5b8c\u6210\u540e&#xff0c;\u5728 pom \u6587\u4ef6\u5f15\u5165 web \u4ee5\u53ca openfeign \u76f8\u5173\u4f9d\u8d56&#xff0c;\u63a5\u7740\u628a\u63a5\u53e3\u65b9\u6cd5\u3001\u5b9e\u4f53\u6a21\u578b\u590d\u5236\u5230\u8fd9\u4e2a\u516c\u5171\u6a21\u5757&#xff0c;\u7f16\u5199\u516c\u5171\u63a5\u53e3&#xff0c;\u5728\u63a5\u53e3\u4e0a\u5b8c\u6574\u5b9a\u4e49\u597d\u6240\u6709\u8bf7\u6c42\u76f8\u5173\u7684 SpringMVC \u6ce8\u89e3\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"341\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193234-6a9090d2c394c.png\" width=\"414\" \/><\/p>\n<p>package com.yang.common.api;<\/p>\n<p>import com.yang.common.model.ProductInfo;<br \/>\nimport org.springframework.cloud.openfeign.SpringQueryMap;<br \/>\nimport org.springframework.web.bind.annotation.PathVariable;<br \/>\nimport org.springframework.web.bind.annotation.RequestBody;<br \/>\nimport org.springframework.web.bind.annotation.RequestMapping;<br \/>\nimport org.springframework.web.bind.annotation.RequestParam;<\/p>\n<p>public interface ProductInterface {<br \/>\n    &#064;RequestMapping(&#034;\/{productId}&#034;)<br \/>\n    ProductInfo getProductById(&#064;PathVariable(&#034;productId&#034;) Integer productId);<\/p>\n<p>    &#064;RequestMapping(&#034;\/p1&#034;)<br \/>\n    String p1(&#064;RequestParam(&#034;id&#034;) Integer id);<\/p>\n<p>    &#064;RequestMapping(&#034;\/p2&#034;)<br \/>\n    String p2(&#064;RequestParam(&#034;id&#034;) Integer id, &#064;RequestParam(&#034;name&#034;) String name);<\/p>\n<p>    &#064;RequestMapping(&#034;\/p3&#034;)<br \/>\n    String p3(&#064;SpringQueryMap ProductInfo productInfo);<\/p>\n<p>    &#064;RequestMapping(&#034;\/p4&#034;)<br \/>\n    String p4(&#064;RequestBody ProductInfo productInfo);<br \/>\n}<br \/>\npackage com.yang.common.model;<\/p>\n<p>import lombok.Data;<\/p>\n<p>import java.util.Date;<\/p>\n<p>&#064;Data<br \/>\npublic class ProductInfo {<br \/>\n    private Integer id;<br \/>\n    private String productName;<br \/>\n    private Integer productPrice;<br \/>\n    private Integer state;<br \/>\n    private Date createTime;<br \/>\n    private Date updateTime;<br \/>\n} <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5b8c\u6210\u4ee3\u7801\u7f16\u5199\u4e4b\u540e&#xff0c;\u901a\u8fc7 Maven \u6267\u884c\u6253\u5305\u3001install \u547d\u4ee4&#xff0c;\u5c06\u751f\u6210\u7684 Jar \u5305\u5b89\u88c5\u5230\u672c\u5730 Maven \u4ed3\u5e93&#xff0c;\u786e\u8ba4 Jar \u5305\u6784\u5efa\u6210\u529f\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"467\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193234-6a9090d2dde62.png\" width=\"426\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5bf9\u4e8e\u670d\u52a1\u63d0\u4f9b\u65b9&#xff0c;\u53ea\u9700\u8981\u8ba9 Controller \u7c7b\u5b9e\u73b0\u521a\u521a\u5b9a\u4e49\u597d\u7684\u516c\u5171\u63a5\u53e3&#xff0c;\u7136\u540e\u91cd\u5199\u63a5\u53e3\u4e2d\u7684\u4e1a\u52a1\u65b9\u6cd5&#xff0c;\u5b8c\u6210\u4e1a\u52a1\u903b\u8f91\u5b9e\u73b0\u5373\u53ef&#xff0c;\u4e0d\u9700\u8981\u518d\u91cd\u590d\u4e66\u5199 RequestMapping \u7b49\u8bf7\u6c42\u6ce8\u89e3\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5bf9\u4e8e\u670d\u52a1\u6d88\u8d39\u65b9&#xff0c;\u521b\u5efa Feign \u5ba2\u6237\u7aef\u63a5\u53e3&#xff0c;\u6dfb\u52a0&#064;FeignClient\u6ce8\u89e3&#xff0c;\u76f4\u63a5\u7ee7\u627f\u6765\u81ea\u516c\u5171\u6a21\u5757\u7684\u63a5\u53e3&#xff0c;\u4e0d\u9700\u8981\u518d\u91cd\u590d\u5b9a\u4e49\u63a5\u53e3\u65b9\u6cd5\u3002\u5b8c\u6210\u540e\u542f\u52a8\u9879\u76ee&#xff0c;\u53d1\u8d77\u8fdc\u7a0b\u8c03\u7528\u8fdb\u884c\u529f\u80fd\u6d4b\u8bd5\u3002<\/p>\n<h3 id=\"5.2.%C2%A0Feign%20%E6%8A%BD%E5%8F%96%E7%8B%AC%E7%AB%8B%E6%A8%A1%E5%9D%97\" style=\"background-color:transparent\">5.2.\u00a0Feign \u62bd\u53d6\u72ec\u7acb\u6a21\u5757<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u867d\u7136\u5b98\u65b9\u63a8\u8350\u7ee7\u627f\u7684\u5b9e\u73b0\u65b9\u5f0f&#xff0c;\u4f46\u662f\u5728\u771f\u5b9e\u4f01\u4e1a\u5f00\u53d1\u5f53\u4e2d&#xff0c;\u66f4\u5e38\u91c7\u7528\u5c06 Feign \u63a5\u53e3\u62bd\u53d6\u4e3a\u72ec\u7acb\u6a21\u5757\u7684\u65b9\u6848\u3002\u8be5\u65b9\u6848\u548c\u7ee7\u627f\u6a21\u5f0f\u64cd\u4f5c\u4e0a\u6709\u76f8\u4f3c\u4e4b\u5904&#xff0c;\u4f46\u8bbe\u8ba1\u7406\u5ff5\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8be5\u65b9\u6848\u7684\u5904\u7406\u903b\u8f91\u662f&#xff0c;\u5c06\u5b8c\u6574\u7684Feign Client\u5ba2\u6237\u7aef\u4ee5\u53ca\u4e1a\u52a1\u6d89\u53ca\u7684\u5b9e\u4f53\u7c7b\u5168\u90e8\u62bd\u53d6\u5230\u72ec\u7acbModule\u6a21\u5757&#xff0c;\u5c06\u6a21\u5757\u6253\u5305\u4e3aJar\u5305&#xff0c;\u670d\u52a1\u6d88\u8d39\u65b9\u76f4\u63a5\u5f15\u5165\u8fd9\u4e2aJar\u5305\u5c31\u53ef\u4ee5\u83b7\u5f97Feign\u8c03\u7528\u80fd\u529b\u3002\u5728\u4f01\u4e1a\u9879\u76ee\u4e2d&#xff0c;\u8fd9\u4e2a\u516c\u5171Jar\u5305\u4e00\u822c\u7531\u670d\u52a1\u63d0\u4f9b\u65b9\u8d1f\u8d23\u7ef4\u62a4\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9996\u5148\u65b0\u5efa\u72ec\u7acb Module \u6a21\u5757&#xff0c;\u5728\u6a21\u5757\u4e2d\u5f15\u5165 openfeign \u4f9d\u8d56&#xff0c;\u628a Feign \u5ba2\u6237\u7aef\u63a5\u53e3\u3001\u5b9e\u4f53Model\u7c7b\u5168\u90e8\u590d\u5236\u5230\u6b64\u6a21\u5757\u4e2d\u3002\u901a\u8fc7 Maven \u6267\u884c install&#xff0c;\u5c06\u8be5\u6a21\u5757\u6253\u5305\u5b89\u88c5\u5230\u672c\u5730\u4ed3\u5e93\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u670d\u52a1\u6d88\u8d39\u65b9\u505a\u5982\u4e0b\u4fee\u6539&#xff1a;\u5220\u9664\u9879\u76ee\u5185\u90e8\u539f\u672c\u624b\u5199\u7684 Feign \u63a5\u53e3\u4e0e\u5b9e\u4f53\u7c7b&#xff0c;\u5728 pom \u5f53\u4e2d\u5f15\u5165\u521a\u521a\u6253\u5305\u597d\u7684\u516c\u5171 Jar \u4f9d\u8d56&#xff0c;\u4fee\u6539\u4ee3\u7801\u5f53\u4e2d\u5b9e\u4f53\u7c7b\u3001\u63a5\u53e3\u7684\u5bfc\u5165\u8def\u5f84&#xff0c;\u6307\u5411Jar\u5305\u5185\u7684\u7c7b\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7531\u4e8e Feign \u63a5\u53e3\u5b58\u653e\u5728\u5916\u90e8 Jar&#xff0c;\u542f\u52a8\u7c7b\u4e0a\u7684 &#064;EnableFeignClients \u6ce8\u89e3\u9700\u8981\u6307\u5b9a\u626b\u63cf\u8303\u56f4&#xff0c;\u6709\u4e24\u79cd\u914d\u7f6e\u65b9\u5f0f&#xff0c;\u7b2c\u4e00\u79cd\u901a\u8fc7 basePackages \u6307\u5b9a\u626b\u63cf\u7684\u5305\u8def\u5f84&#xff1b;\u7b2c\u4e8c\u79cd\u901a\u8fc7 clients \u5c5e\u6027\u76f4\u63a5\u6307\u5b9a\u8981\u52a0\u8f7d\u7684 Feign \u5ba2\u6237\u7aef Class \u5bf9\u8c61\u3002\u914d\u7f6e\u5b8c\u6210\u540e&#xff0c;\u542f\u52a8\u9879\u76ee\u8fdb\u884c\u8fdc\u7a0b\u8c03\u7528\u6d4b\u8bd5\u3002<\/p>\n<p>package com.yang.order;<\/p>\n<p>import com.yang.common.api.ProductApi;<br \/>\nimport org.springframework.boot.SpringApplication;<br \/>\nimport org.springframework.boot.autoconfigure.SpringBootApplication;<br \/>\nimport org.springframework.cloud.openfeign.EnableFeignClients;<\/p>\n<p>&#064;EnableFeignClients(clients &#061; {ProductApi.class})<br \/>\n&#064;SpringBootApplication<br \/>\npublic class OrderServiceApplication {<br \/>\n    public static void main(String[] args) {<br \/>\n        SpringApplication.run(OrderServiceApplication.class, args);<br \/>\n    }<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e13\u680f&#xff1a;Spring Cloud \u4e2a\u4eba\u4e3b\u9875&#xff1a;\u624b\u63e1\u98ce\u4e91 \u76ee\u5f55<br \/>\n\u4e00\u3001RestTemplate \u7684\u95ee\u9898<br \/>\n\u4e8c\u3001OpenFeign \u4ecb\u7ecd<br \/>\n\u4e09\u3001OpenFeign \u5feb\u901f\u4e0a\u624b<br \/>\n3.1.\u00a0\u5f15\u5165\u4f9d\u8d56<br \/>\n3.2.\u00a0\u5f00\u542f\u529f\u80fd<br \/>\n3.3.\u00a0\u7f16\u5199 Feign \u5ba2\u6237\u7aef\u63a5\u53e3<br \/>\n3.4.\u00a0\u8c03\u7528\u8fdc\u7a0b\u63a5\u53e3<br \/>\n\u56db\u3001OpenFeign \u53c2\u6570\u4f20\u9012<br \/>\n4.1.\u00a0\u5355\u4e2a\u666e\u901a\u53c2\u6570&#xff08;Query \u53c2\u6570&#xff09;<br \/>\n4.2.\u00a0\u591a\u4e2a\u666e\u901a\u53c2\u6570<br \/>\n4.3.\u00a0\u5bf9\u8c61\u4f5c\u4e3a Query \u53c2\u6570<\/p>\n","protected":false},"author":2,"featured_media":96624,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[101,963,292],"topic":[],"class_list":["post-96630","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-spring","tag-spring-cloud","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/96630.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e13\u680f&#xff1a;Spring Cloud \u4e2a\u4eba\u4e3b\u9875&#xff1a;\u624b\u63e1\u98ce\u4e91 \u76ee\u5f55 \u4e00\u3001RestTemplate \u7684\u95ee\u9898 \u4e8c\u3001OpenFeign \u4ecb\u7ecd \u4e09\u3001OpenFeign \u5feb\u901f\u4e0a\u624b 3.1.\u00a0\u5f15\u5165\u4f9d\u8d56 3.2.\u00a0\u5f00\u542f\u529f\u80fd 3.3.\u00a0\u7f16\u5199 Feign \u5ba2\u6237\u7aef\u63a5\u53e3 3.4.\u00a0\u8c03\u7528\u8fdc\u7a0b\u63a5\u53e3 \u56db\u3001OpenFeign \u53c2\u6570\u4f20\u9012 4.1.\u00a0\u5355\u4e2a\u666e\u901a\u53c2\u6570&#xff08;Query \u53c2\u6570&#xff09; 4.2.\u00a0\u591a\u4e2a\u666e\u901a\u53c2\u6570 4.3.\u00a0\u5bf9\u8c61\u4f5c\u4e3a Query \u53c2\u6570\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/96630.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-27T19:32:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193233-6a9090d1f0697.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96630.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/96630.html\",\"name\":\"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-27T19:32:36+00:00\",\"dateModified\":\"2026-08-27T19:32:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/96630.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/96630.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/96630.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/96630.html","og_locale":"zh_CN","og_type":"article","og_title":"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e13\u680f&#xff1a;Spring Cloud \u4e2a\u4eba\u4e3b\u9875&#xff1a;\u624b\u63e1\u98ce\u4e91 \u76ee\u5f55 \u4e00\u3001RestTemplate \u7684\u95ee\u9898 \u4e8c\u3001OpenFeign \u4ecb\u7ecd \u4e09\u3001OpenFeign \u5feb\u901f\u4e0a\u624b 3.1.\u00a0\u5f15\u5165\u4f9d\u8d56 3.2.\u00a0\u5f00\u542f\u529f\u80fd 3.3.\u00a0\u7f16\u5199 Feign \u5ba2\u6237\u7aef\u63a5\u53e3 3.4.\u00a0\u8c03\u7528\u8fdc\u7a0b\u63a5\u53e3 \u56db\u3001OpenFeign \u53c2\u6570\u4f20\u9012 4.1.\u00a0\u5355\u4e2a\u666e\u901a\u53c2\u6570&#xff08;Query \u53c2\u6570&#xff09; 4.2.\u00a0\u591a\u4e2a\u666e\u901a\u53c2\u6570 4.3.\u00a0\u5bf9\u8c61\u4f5c\u4e3a Query \u53c2\u6570","og_url":"https:\/\/www.wsisp.com\/helps\/96630.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-27T19:32:36+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260827193233-6a9090d1f0697.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/96630.html","url":"https:\/\/www.wsisp.com\/helps\/96630.html","name":"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-27T19:32:36+00:00","dateModified":"2026-08-27T19:32:36+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/96630.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/96630.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/96630.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Spring Cloud\uff1a\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u201c\u7c98\u5408\u5242\u201d\uff08\u4e03\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=96630"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/96630\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/96624"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=96630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=96630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=96630"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=96630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}