{"id":2970,"date":"2018-08-08T10:48:19","date_gmt":"2018-08-08T02:48:19","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2970"},"modified":"2018-08-08T10:48:19","modified_gmt":"2018-08-08T02:48:19","slug":"spring-cloud-%e6%95%99%e7%a8%8b%e7%ac%ac%e4%ba%94%e7%ab%a0-feign-%e7%9a%84%e5%a3%b0%e6%98%8e%e5%bc%8f%e6%9c%8d%e5%8a%a1%e8%b0%83%e7%94%a8%e4%b8%8e%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2970","title":{"rendered":"Spring Cloud \u6559\u7a0b\u7b2c\u4e94\u7ae0 Feign \u7684\u58f0\u660e\u5f0f\u670d\u52a1\u8c03\u7528\u4e0e\u8d1f\u8f7d\u5747\u8861"},"content":{"rendered":"<p>\n\t\u7f51\u4e0a\u5f88\u5c11\u6709\u4eba\u628a&nbsp;Feign \u5355\u72ec\u4f5c\u4e3a\u4e00\u7ae0\u6765\u5199\uff0c\u4f46\u6211\u8ba4\u4e3a Feign \u4e5f\u5f88\u91cd\u8981\uff0c\u4f7f\u7528\u597d&nbsp;Feign \u80fd\u66f4\u597d\u7684\u7406\u89e3 RESTFUL \u63a5\u53e3\u8bbe\u8ba1\u89c4\u8303\u3002\u5982\u679c\u60f3\u8981\u7528\u4e00\u7bc7\u6587\u7ae0\u6765\u5199\u597d&nbsp;Feign \u6211\u8ba4\u4e3a\u662f\u5f88\u96be\u7684\uff0c\u6211\u5c3d\u91cf\u7528\u4e00\u7bc7\u6587\u7ae0\u6765\u63cf\u8ff0\u6e05\u695a\u3002\n<\/p>\n<p>\n\tFeign \u662f\u4e00\u4e2a\u58f0\u660e\u5f0f Web Service \u5ba2\u6237\u7aef\u3002\u4f7f\u7528Feign\u80fd\u8ba9\u7f16\u5199Web Service\u5ba2\u6237\u7aef\u66f4\u52a0\u7b80\u5355, \u5b83\u7684\u4f7f\u7528\u65b9\u6cd5\u662f\u5b9a\u4e49\u4e00\u4e2a\u63a5\u53e3\uff0c\u7136\u540e\u5728\u4e0a\u9762\u6dfb\u52a0\u6ce8\u89e3\uff0c\u540c\u65f6\u4e5f\u652f\u6301JAX-RS\u6807\u51c6\u7684\u6ce8\u89e3\u3002Feign\u4e5f\u652f\u6301\u53ef\u62d4\u63d2\u5f0f\u7684\u7f16\u7801\u5668\u548c\u89e3\u7801\u5668\u3002Spring Cloud \u5bf9 Feign \u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u4f7f\u5176\u652f\u6301\u4e86 Spring MVC \u6807\u51c6\u6ce8\u89e3\u548c HttpMessageConverters\u3002Feign \u53ef\u4ee5\u4e0e Eureka \u548c Ribbon \u7ec4\u5408\u4f7f\u7528\u4ee5\u652f\u6301\u8d1f\u8f7d\u5747\u8861\u3002\n<\/p>\n<p>\n\t\u5728 Spring Cloud \u4e2d&nbsp;Feign \u662f\u7528\u4f5c\u670d\u52a1\u8c03\u7528\u548c\u5ba2\u6237\u7aef\u8d1f\u8f7d\u5747\u8861\u7684\u3002Feign \u53ef\u4ee5\u914d\u5408 Spring Cloud \u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u5355\u72ec\u4f7f\u7528\u3002\n<\/p>\n<p>\n\t\u5728\u4e0d\u4f7f\u7528&nbsp;Feign \u4e4b\u524d\uff0c\u6211\u4eec\u8c03\u7528\u5176\u5b83\u670d\u52a1\u9700\u8981\u7528\u5230&nbsp;httpclient \u6216\u8005 okhttp \u8fd9\u6837\u76f8\u5bf9\u8f83\u91cd\u7684\u6846\u67b6\uff0c\u800c\u4e14\u9700\u8981\u7f16\u5199\u5927\u91cf\u7684\u4ee3\u7801\u3002\u867d\u7136&nbsp;spring \u4e2d RestTemplate \u4e5f\u53ef\u4ee5\u7075\u6d3b\u7684\u4f7f\u7528\uff0c\u4f46\u662f\u5b83\u4e0d\u5177\u5907\u8d1f\u8f7d\u5747\u8861\u7684\u529f\u80fd\uff0c\u9700\u8981\u6211\u4eec\u81ea\u5df1\u5b9e\u73b0\uff1b\u53e6\u5916&nbsp;RestTemplate \u5bf9\u914d\u7f6e\u5316\uff0c\u652f\u6301\u7684\u8fd8\u4e0d\u591f\u53cb\u597d\uff0c\u6240\u4ee5&nbsp;Feign \u5e94\u8fd0\u800c\u751f\u3002\n<\/p>\n<p>\n\t\u6211\u4eec\u5148\u6765\u770b\u770b Feign \u7684\u5355\u72ec\u4f7f\u7528\u3002\u9996\u5148\uff0c\u9700\u8981\u5bfc\u5165 Maven \u7684\u76f8\u5173\u914d\u7f6e\uff1a\n<\/p>\n<pre>\r\n&lt;properties&gt;\r\n    &lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;\r\n    &lt;project.reporting.sourceEncoding&gt;UTF-8&lt;\/project.reporting.sourceEncoding&gt;\r\n    &lt;java.version&gt;1.7&lt;\/java.version&gt;\r\n&lt;\/properties&gt;\r\n\r\n&lt;dependencies&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.google.code.gson&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;gson&lt;\/artifactId&gt;\r\n        &lt;version&gt;2.8.2&lt;\/version&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.netflix.feign&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;feign-core&lt;\/artifactId&gt;\r\n        &lt;version&gt;8.18.0&lt;\/version&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;com.netflix.feign&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;feign-gson&lt;\/artifactId&gt;\r\n        &lt;version&gt;8.18.0&lt;\/version&gt;\r\n    &lt;\/dependency&gt;\r\n&lt;\/dependencies&gt;<\/pre>\n<p>\n\t\u7136\u540e\u81ea\u5b9a\u4e49\u4e00\u4e2a\u8fdc\u7a0b\u8c03\u7528\u63a5\u53e3\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npublic interface GitHub {\r\n    @RequestLine(&quot;GET \/repos\/{owner}\/{repo}\/contributors&quot;)\r\n    List&lt;Contributor&gt; contributors(@Param(&quot;owner&quot;) String owner, @Param(&quot;repo&quot;) String repo);\r\n}<\/pre>\n<p>\n\t\u4e0a\u9762\u7684&nbsp;Contributor \u7c7b\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npublic class Contributor {\r\n    String login;\r\n    int contributions;\r\n}<\/pre>\n<p>\n\t\u7136\u540e\u5bf9 Feign \u7684\u8fdc\u7a0b\u8c03\u7528\u529f\u80fd\u8fdb\u884c\u6d4b\u8bd5\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npublic class FeignTest {\r\n    public static void main(String... args) {\r\n        \/\/www.xttblog.com\r\n        GitHub github = Feign.builder()\r\n                .decoder(new GsonDecoder())\r\n                .target(GitHub.class, &quot;https:\/\/api.github.com&quot;);\r\n\r\n        \/\/ Fetch and print a list of the contributors to this library.\r\n        List&lt;Contributor&gt; contributors = github.contributors(&quot;OpenFeign&quot;, &quot;feign&quot;);\r\n        for (Contributor contributor : contributors) {\r\n            System.out.println(contributor.login + &quot; (&quot; + contributor.contributions + &quot;)&quot;);\r\n        }\r\n    }\r\n}<\/pre>\n<p>\n\t\u8fd0\u884c\u540e\uff0c\u8f93\u51fa\u7684\u7ed3\u679c\u6211\u5c31\u4e0d\u5199\u4e86\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u7684\u53bb\u6d4b\u8bd5\u3002\u76f8\u5173\u4ee3\u7801\u6211\u5df2\u4e0a\u4f20\u5230&nbsp;<a href=\"https:\/\/github.com\/xmt1139057136\/xttblog-cloud\/xttblog-feign-github\" name=\"Feign \u7684\u8fdc\u7a0b\u8c03\u7528\u6848\u4f8b\u6e90\u7801\" target=\"_blank\" title=\"Feign \u7684\u8fdc\u7a0b\u8c03\u7528\u6848\u4f8b\u6e90\u7801\">https:\/\/github.com\/xmt1139057136\/xttblog-cloud\/xttblog-feign-github<\/a>\u3002\n<\/p>\n<p>\n\t\u4e0a\u9762\u7684\u6848\u4f8b\uff0c\u6211\u4eec\u4e3b\u8981\u662f\u5bf9 Feign \u6709\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u8ba4\u8bc6\uff0c\u5728 Spring Cloud \u4e2d\u5e76\u4e0d\u4f1a\u8fd9\u6837\u7684\u53bb\u4f7f\u7528\u3002\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770b\u5728 Spring Cloud \u4e2d\u5982\u4f55\u4f7f\u7528 Feign\u3002\n<\/p>\n<p>\n\t\u9996\u5148\u521b\u5efa\u4e00\u4e2a&nbsp;xttblog-cloud-producer \u9879\u76ee\u3002pom.xml \u914d\u7f6e\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;parent&gt;\r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n        &lt;version&gt;1.5.13.RELEASE&lt;\/version&gt;\r\n    &lt;\/parent&gt;\r\n    &lt;dependencyManagement&gt;\r\n        &lt;dependencies&gt;\r\n            &lt;dependency&gt;\r\n                &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n                &lt;artifactId&gt;spring-cloud-dependencies&lt;\/artifactId&gt;\r\n                &lt;version&gt;Edgware.SR4&lt;\/version&gt;\r\n                &lt;type&gt;pom&lt;\/type&gt;\r\n                &lt;scope&gt;import&lt;\/scope&gt;\r\n            &lt;\/dependency&gt;\r\n        &lt;\/dependencies&gt;\r\n    &lt;\/dependencyManagement&gt;\r\n    &lt;dependencies&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-config&lt;\/artifactId&gt;\r\n        &lt;\/dependency&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-eureka&lt;\/artifactId&gt;\r\n        &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;<\/pre>\n<p>\n\tapplication.yml \u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nserver:\r\n  port: 8888\r\n\r\neureka:\r\n  instance:\r\n    hostname: localhost\r\n  client:\r\n    serviceUrl:\r\n      defaultZone: http:\/\/${eureka.instance.hostname}:8761\/eureka\/\r\n\r\nspring:\r\n  application:\r\n    name: xttblog-cloud-producer<\/pre>\n<p>\n\t\u7136\u540e\u7f16\u5199\u4e00\u4e2a\u670d\u52a1\u63d0\u4f9b\u8005\u7684 Controller\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@RestController\r\n@RequestMapping(&quot;\/cal&quot;)\r\npublic class CalController {\r\n    @RequestMapping(&quot;\/add&quot;)\r\n    public Integer add(@RequestParam Integer a, @RequestParam Integer b){\r\n        return a + b;\r\n    }\r\n}<\/pre>\n<p>\n\t\u542f\u52a8\u7c7b\u7684\u4ee3\u7801\u6ca1\u6709\u5927\u7684\u6539\u52a8\uff0c\u5177\u4f53\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@SpringBootApplication\r\n@EnableDiscoveryClient\r\npublic class XttblogProducerApplication {\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(XttblogProducerApplication.class, args);\r\n    }\r\n}<\/pre>\n<p>\n\t\u81f3\u6b64\uff0c\u670d\u52a1\u63d0\u4f9b\u8005\u6211\u4eec\u5df2\u7ecf\u5199\u5b8c\u4e86\uff0c\u4e0b\u9762\u6211\u4eec\u6765\u7f16\u5199\u670d\u52a1\u8c03\u7528\u7740\u4ee3\u7801\u3002\u540c\u6837\u7684\u5148\u65b0\u5efa\u4e00\u4e2a&nbsp;xttblog-cloud-consumer \u5de5\u7a0b\u3002pom.xml \u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;parent&gt;\r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n        &lt;version&gt;1.5.13.RELEASE&lt;\/version&gt;\r\n    &lt;\/parent&gt;\r\n    &lt;dependencyManagement&gt;\r\n        &lt;dependencies&gt;\r\n            &lt;dependency&gt;\r\n                &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n                &lt;artifactId&gt;spring-cloud-dependencies&lt;\/artifactId&gt;\r\n                &lt;version&gt;Edgware.SR4&lt;\/version&gt;\r\n                &lt;type&gt;pom&lt;\/type&gt;\r\n                &lt;scope&gt;import&lt;\/scope&gt;\r\n            &lt;\/dependency&gt;\r\n        &lt;\/dependencies&gt;\r\n    &lt;\/dependencyManagement&gt;\r\n    &lt;dependencies&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-config&lt;\/artifactId&gt;\r\n        &lt;\/dependency&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-eureka&lt;\/artifactId&gt;\r\n        &lt;\/dependency&gt;\r\n\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-starter-feign&lt;\/artifactId&gt;\r\n        &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;<\/pre>\n<p>\n\t\u63a5\u7740\u662f&nbsp;application.yml \u6587\u4ef6\u7684\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nserver:\r\n  port: 7777\r\n\r\neureka:\r\n  instance:\r\n    hostname: localhost\r\n  client:\r\n    serviceUrl:\r\n      defaultZone: http:\/\/${eureka.instance.hostname}:8761\/eureka\/\r\n\r\nspring:\r\n  application:\r\n    name: xttblog-cloud-consumer<\/pre>\n<p>\n\t\u518d\u63a5\u7740\u662f\u6d88\u8d39\u8005\u7684 Controller \u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@RestController\r\n@RequestMapping(&quot;\/test&quot;)\r\npublic class ConsumerController {\r\n\r\n    @Autowired\r\n    private CalService calService;\r\n\r\n    @Autowired\r\n    private CalRemoteService calRemoteService;\r\n\r\n    @RequestMapping(&quot;\/add&quot;)\r\n    public String add(@RequestParam Integer a, @RequestParam Integer b){\r\n        return a + &quot;+&quot; + b + &quot;\u7684RestTemplate\u8c03\u7528\u7ed3\u679c\u4e3a\uff1a&quot; + calService.add(a, b);\r\n    }\r\n\r\n    @RequestMapping(&quot;\/radd&quot;)\r\n    public String rAdd(@RequestParam Integer a, @RequestParam Integer b){\r\n        return a + &quot;+&quot; + b + &quot;\u7684Cloud\u8c03\u7528\u7ed3\u679c\u4e3a\uff1a&quot; + calRemoteService.add(a, b);\r\n    }\r\n}<\/pre>\n<p>\n\t\u7136\u540e\u662f Feign \u7684\u8fdc\u7a0b\u8c03\u7528\u7684\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@FeignClient(name= &quot;xttblog-cloud-producer&quot;)\r\npublic interface CalRemoteService {\r\n    @RequestMapping(value = &quot;\/cal\/add&quot;)\r\n    public String add(@RequestParam(value=&quot;a&quot;) Integer a, @RequestParam(&quot;b&quot;) Integer b);\r\n}<\/pre>\n<pre class=\"brush:java;\">\r\npublic interface CalService {\r\n    public String add(Integer a, Integer b);\r\n}<\/pre>\n<pre class=\"brush:java;\">\r\n@Service\r\npublic class CalServiceImpl implements CalService{\r\n\r\n    @Autowired\r\n    private RestTemplate restTemplate;\r\n\r\n    @Bean\r\n    \/\/@LoadBalanced\/\/\u542f\u7528ribbon\u8d1f\u8f7d\u5747\u8861\u8c03\u7528\u670d\u52a1\r\n    public RestTemplate cteateRestTemplate(){\r\n        return new RestTemplate();\r\n    }\r\n\r\n    @Override\r\n    public String add(Integer a, Integer b) {\r\n        String url = &quot;http:\/\/localhost:8888\/cal\/add?a=&quot; + a + &quot;&amp;b=&quot; + b;\r\n        ResponseEntity responseEntity = restTemplate.getForEntity(url,String.class);\r\n        return responseEntity.getBody().toString();\r\n    }\r\n}<\/pre>\n<p>\n\t\u6211\u8fd9\u91cc\u6709\u4e24\u4e2a Service \u7c7b\uff0c\u4e00\u4e2a\u662f\u4f7f\u7528 RestTemplate \u8c03\u7528\u670d\u52a1\uff0c\u4e00\u4e2a\u662f Feign \u6765\u8c03\u7528\uff1b\u8ba9\u5927\u5bb6\u6bd4\u8f83\u4e00\u4e0b\u4e24\u8005\u7684\u8c03\u7528\u65b9\u5f0f\u3002\n<\/p>\n<p>\n\t\u5728\u4f7f\u7528&nbsp;@FeignClient \u6ce8\u89e3\u540e\uff0c\u5fc5\u987b\u5728\u4e3b\u542f\u52a8\u7c7b\u4e0a\u52a0\u4e0a&nbsp;@EnableFeignClients \u6ce8\u89e3\uff0c\u5426\u5219\u8c03\u7528\u4e0d\u4f1a\u6210\u529f\u3002\n<\/p>\n<pre class=\"brush:java;\">\r\n@SpringBootApplication\r\n@EnableDiscoveryClient\r\n@EnableFeignClients\r\npublic class XttblogConsumerApplication {\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(XttblogConsumerApplication.class, args);\r\n    }\r\n}<\/pre>\n<p>\n\t\u53e6\u5916\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u670d\u52a1\u6d88\u8d39\u65b9\u5fc5\u987b\u5f15\u5165 Feign \u7684\u4f9d\u8d56\uff0c\u5426\u5219\u542f\u52a8\u65f6\u4f1a\u62a5\u9519\u3002\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;dependency&gt;\r\n    &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-cloud-starter-feign&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>\n\t\u90a3\u6709\u4eba\u4f1a\u95ee\u4e86\uff0c\u4e3a\u4ec0\u4e48\u6211\u5f15\u5165\u6ce8\u89e3\u65f6\u4e0d\u62a5\u9519\uff0c\u800c\u662f\u5728\u8fd0\u884c\u65f6\u624d\u62a5\u9519\u5462\uff1f\u90a3\u662f\u56e0\u4e3a\u6211\u4eec\u90fd\u662f\u9762\u5411\u63a5\u53e3\u7f16\u7a0b\u7684\u3002\u5f15\u5165\u6ce8\u89e3\uff0c\u5e76\u6ca1\u6709\u5f15\u5165 Feign \u7684\u5b9e\u73b0\uff0c\u6240\u4ee5\u4f1a\u62a5\u9519\u3002\n<\/p>\n<p>\n\t\u4e0a\u9762\u4e24\u4e2a\u670d\u52a1\uff0c\u6211\u4eec\u90fd\u6ce8\u518c\u5230\u4e86 Eureka\uff0c\u7528\u7684\u662f Spring Cloud \u6559\u7a0b\u7cfb\u5217\u7b2c\u4e8c\u7ae0\u7684\u670d\u52a1\u6ce8\u518c\u5de5\u7a0b\u300a<a href=\"https:\/\/www.xttblog.com\/?p=2957\">Spring Cloud \u6559\u7a0b\u7b2c\u4e8c\u7ae0 \u670d\u52a1\u7684\u6ce8\u518c\u3001\u53d1\u73b0\u3001\u6cbb\u7406\u4e4b Eureka \u5b9e\u6218<\/a>\u300b\uff0c\u5177\u4f53\u53ef\u4ee5\u5230\u6211\u7684 github \u4e0a\u67e5\u770b\u6e90\u7801\uff1a<a href=\"https:\/\/github.com\/xmt1139057136\/xttblog-cloud\/tree\/master\/xttblog-eureka-server\" name=\"Eureka \u6559\u7a0b\" target=\"_blank\" title=\"Eureka \u6559\u7a0b\">https:\/\/github.com\/xmt1139057136\/xttblog-cloud\/tree\/master\/xttblog-eureka-server<\/a>\u3002\n<\/p>\n<p>\n\t\u5199\u5b8c\u4e0a\u9762\u7684\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u4f9d\u6b21\u542f\u52a8\uff0cxttblog-eureka-server\u3001xttblog-cloud-producer\u3001xttblog-cloud-consumer\u3002\u7136\u540e\u6d4f\u89c8\u5668\u5730\u5740\u680f\u91cc\u8f93\u5165&nbsp;http:\/\/localhost:7777\/test\/add?a=1&amp;b=2 \u548c&nbsp;http:\/\/localhost:7777\/test\/radd?a=1&amp;b=3 \u5373\u53ef\u770b\u5230\u8fd0\u884c\u6548\u679c\u3002\n<\/p>\n<p>\n\t\u6700\u540e\u672c\u6587\u6d89\u53ca\u7684\u76f8\u5173\u6e90\u7801\u90fd\u5df2\u4e0a\u4f20\u5230\uff1a<a href=\"https:\/\/github.com\/xmt1139057136\/xttblog-cloud\" name=\"Spring Cloud \u6559\u7a0b\" target=\"_blank\" title=\"Spring Cloud \u6559\u7a0b\">https:\/\/github.com\/xmt1139057136\/xttblog-cloud<\/a>\uff0c\u559c\u6b22\u7684\u53ef\u4ee5\u7ed9\u4e2a star\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2970\">Spring Cloud \u6559\u7a0b\u7b2c\u4e94\u7ae0 Feign \u7684\u58f0\u660e\u5f0f\u670d\u52a1\u8c03\u7528\u4e0e\u8d1f\u8f7d\u5747\u8861<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u7f51\u4e0a\u5f88\u5c11\u6709\u4eba\u628a&nbsp;Feign \u5355\u72ec\u4f5c\u4e3a\u4e00\u7ae0\u6765\u5199\uff0c\u4f46\u6211\u8ba4\u4e3a Feign \u4e5f\u5f88\u91cd\u8981\uff0c\u4f7f\u7528\u597d&nbsp;Fe [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1642,1659,587,588,581],"class_list":["post-2970","post","type-post","status-publish","format-standard","hentry","category-java","tag-eureka","tag-feign","tag-spring-boot","tag-spring-cloud","tag-581"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2970"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2970\/revisions"}],"predecessor-version":[{"id":2971,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2970\/revisions\/2971"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}