{"id":644,"date":"2023-03-23T21:42:05","date_gmt":"2023-03-23T13:42:05","guid":{"rendered":""},"modified":"2023-03-23T21:42:05","modified_gmt":"2023-03-23T13:42:05","slug":"SpringCloud Zuul API\u7f51\u5173","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/644.html","title":{"rendered":"SpringCloud Zuul API\u7f51\u5173"},"content":{"rendered":"
\n
\u8eab\u4efd\u9a8c\u8bc1\u548c\u5b89\u5168\u6027: <\/strong>\u5b83\u63d0\u4f9b\u4e86\u6bcf\u79cd\u8d44\u6e90\u7684\u8eab\u4efd\u9a8c\u8bc1\u8981\u6c42\u3002<\/span> zuul-core: <\/strong> \u5b83\u662f\u4e00\u4e2a\u5305\u542bZuul 2.0\u6838\u5fc3\u529f\u80fd\u7684\u5e93\u3002<\/span> zuul-core: <\/strong>\u3002\u5b83\u5b9a\u4e49\u4e86\u6838\u5fc3\u529f\u80fd\u3002<\/span> \u4e3aZuul API\u7f51\u5173\u521b\u5efa\u4e00\u4e2a\u7ec4\u4ef6<\/span> <\/code>\n <\/div>\n <\/code>\n <\/div>\n <\/body>
\n \u6d1e\u5bdf\u548c\u76d1\u89c6: <\/strong>\u5b83\u8ddf\u8e2a\u6709\u610f\u4e49\u7684\u6570\u636e\u548c\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f7f\u6211\u4eec\u53ef\u4ee5\u51c6\u786e\u5730\u4e86\u89e3\u751f\u4ea7\u60c5\u51b5\u3002<\/span>
\n \u52a8\u6001\u8def\u7531: <\/strong>\u5b83\u6839\u636e\u9700\u8981\u5c06\u8bf7\u6c42\u52a8\u6001\u8def\u7531\u5230\u5176\u4ed6\u652f\u6301\u7684\u7fa4\u96c6\u3002<\/span>
\n \u538b\u529b\u6d4b\u8bd5: <\/strong>\u5b83\u589e\u52a0\u4e86\u5230\u7fa4\u96c6\u7684\u6d41\u91cf\u4ee5\u6d4b\u8bd5\u6027\u80fd\u3002<\/span>
\n \u8d1f\u8f7d: <\/strong>\u5b83\u4e3a\u6bcf\u79cd\u7c7b\u578b\u7684\u8bf7\u6c42\u5206\u914d\u5bb9\u91cf\uff0c\u5e76\u4e22\u5f03\u8d85\u51fa\u9650\u5236\u7684\u8bf7\u6c42\u3002<\/span>
\n \u9759\u6001\u54cd\u5e94\u5904\u7406: <\/strong>\u5b83\u76f4\u63a5\u5728\u8fb9\u7f18\u6784\u5efa\u4e00\u4e9b\u54cd\u5e94\uff0c\u800c\u4e0d\u662f\u5c06\u5176\u8f6c\u53d1\u5230\u5185\u90e8\u96c6\u7fa4\u3002<\/span>
\n \u591a\u533a\u57df\u5f39\u6027: <\/strong> \u5b83\u8de8AWS\u533a\u57df\u8def\u7531\u8bf7\u6c42\uff0c\u4ee5\u591a\u6837\u5316\u6211\u4eec\u7684ELB\u7528\u6cd5\u3002<\/span> <\/p>\n Zuul\u7ec4\u4ef6<\/h2>\n
\n zuul-sample: <\/strong>\u662fZuul 2.0\u7684\u793a\u4f8b\u9a71\u52a8\u7a0b\u5e8f\u5e94\u7528\u7a0b\u5e8f<\/span> <\/p>\n
\n zuul-simple-webapp: <\/strong>\u4e00\u4e2aWeb\u5e94\u7528\u7a0b\u5e8f\uff0c\u5176\u4e2d\u663e\u793a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u8bf4\u660e\u5982\u4f55\u4f7f\u7528zuul-core\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002<\/span>
\n zuul-netflix: <\/strong>\u662f\u4e00\u4e2a\u5c06\u5176\u4ed6NetflixOSS\u7ec4\u4ef6\u6dfb\u52a0\u5230Zuul\u7684\u5e93\u3002<\/span>
\n zuul-netflix-webapp: <\/strong>\u8fd9\u662f\u4e00\u4e2a\u5c06zuul-core\u548czuul-netflix\u6253\u5305\u5728\u4e00\u8d77\u7684webapp\u3002<\/span> <\/p>\n\u8bbe\u7f6eZuul API\u7f51\u5173\u670d\u52a1\u5668<\/h2>\n
\n \u4e09\u4e2a<\/strong>\u6b65\u9aa4\u6765\u8bbe\u7f6eZuul API\u7f51\u5173:\n <\/div>\n
\n \u786e\u5b9aZuul API\u7f51\u5173\u5e94\u505a\u7684\u4e8b\u60c5<\/span>
\n \u6240\u6709\u91cd\u8981\u8bf7\u6c42\u5747\u914d\u7f6e\u4e3a\u901a\u8fc7Zuul API\u7f51\u5173<\/span> <\/p>\n
\n Spring Initializr <\/strong> https:\/\/start.spring.io \u3002\n <\/div>\n
\n Group<\/strong>\u540d\u79f0\u3002\u6211\u4eec\u5df2\u7ecf\u63d0\u4f9b\u4e86
\n com.lidihuo.microservices\u3002<\/strong>\n <\/div>\n
\n Artifact id<\/strong>\uff0c\u6211\u4eec\u63d0\u4f9b\u4e86
\n netflix-zuul-api-gateway-server\u3002<\/strong>\n <\/div>\n
\n Zuul\uff0cEureka Discovery\uff0cActuator <\/strong>\u548c
\n DevTools\u3002<\/strong>\n <\/div>\n <\/p>\n
\n Generate <\/strong>(\u751f\u6210)\u6309\u94ae\u3002\u5b83\u5c06\u5f00\u59cb\u5c06\u9879\u76ee\u6253\u5305\u5230
\n zip <\/strong>\u6587\u4ef6\u4e2d\u5e76\u4e0b\u8f7d\u3002\n <\/div>\n <\/p>\n
\n netflix-zuul-api-gateway-server <\/strong>->\u9009\u62e9\u6587\u4ef6\u5939->\u5b8c\u6210\n <\/div>\n
\n NetflixZuulApiGatewayServerApplication.java <\/strong>\u6587\u4ef6\u5e76\u542f\u7528zuul\u4ee3\u7406\u548c\u53d1\u73b0\u5206\u522b\u4f7f\u7528
\n @EnableZuulProxy <\/strong>\u548c
\n @EnableDiscoveryClient <\/strong>
\n \u3002<\/strong>\n <\/div>\n\r\npackage <\/span>com.lidihuo.microservices.netflixzuulapigatewayserver;\r\nimport org.springframework.boot.SpringApplication;\r\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\r\nimport org.springframework.cloud.client.discovery.EnableDiscoveryClient;\r\nimport org.springframework.cloud.netflix.zuul.EnableZuulProxy;\r\n@EnableZuulProxy\r\n@EnableDiscoveryClient\r\n@SpringBootApplication\r\npublic <\/span>class <\/span>NetflixZuulApiGatewayServerApplication \r\n{\r\npublic <\/span>static void <\/span>main(String[] args) \r\n{\r\nSpringApplication.run<\/span>(NetflixZuulApiGatewayServerApplication.class, args);\r\n}\r\n}\r\n<\/pre>\n
\n application.properties <\/strong>\u6587\u4ef6\uff0c\u5e76\u914d\u7f6e
\n \u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\uff0c\u7aef\u53e3\uff0c<\/strong>\u548c
\n eureka\u547d\u540d\u670d\u52a1\u5668<\/strong>\u3002\n <\/div>\n\r\nspring.application.name=netflix-zuul-api-gateway-server\r\nserver.port=8765\r\neureka.client.service-url.default-zone=http:\/\/localhost:8765\/eureka\r\n<\/pre>\n
\n
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"SpringCloud Zuul API\u7f51\u5173zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[106],"tags":[],"class_list":["post-644","post","type-post","status-publish","format-standard","hentry","category-bc_springcloud_jc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/644"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=644"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/644\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}