{"id":1954,"date":"2023-04-01T10:17:48","date_gmt":"2023-04-01T02:17:48","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1954"},"modified":"2023-04-22T08:39:05","modified_gmt":"2023-04-22T00:39:05","slug":"spring-cloud-gateway-dynamic-routing-advanced","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/spring-cloud-gateway-dynamic-routing-advanced\/","title":{"rendered":"Spring Cloud Gateway \u52a8\u6001\u8def\u7531 &#8211; \u8fdb\u9636"},"content":{"rendered":"<h2>\u65b9\u6848\u7b80\u4ecb<\/h2>\n<p>\uff081\uff09\u521b\u5efa\u4e00\u4e2a\u8def\u7531\u4fe1\u606f\u7ef4\u62a4\u7684\u9879\u76ee\uff08dynamic-route\uff09\uff0c\u5b9e\u73b0\u589e\u5220\u6539\u67e5\u8def\u7531\u4fe1\u606f\u5230mysql<br \/>\n\uff082\uff09\u63d0\u4f9b\u53d1\u5e03\u529f\u80fd\uff0c\u53d1\u5e03\u540e\u5c06\u8def\u7531\u4fe1\u606f\u4e0e\u7248\u672c\u4fe1\u606f\u4fdd\u5b58\u5230redis\u4e2d\uff0c\u5bf9\u5916\u63d0\u4f9b rest \u63a5\u53e3\u83b7\u53d6\u8def\u7531\u4fe1\u606f<br \/>\n\uff083\uff09\u7f51\u5173\uff08gateway-dynamic-route\uff09\u5f00\u542f\u5b9a\u65f6\u4efb\u52a1\uff0c\u5b9a\u65f6\u62c9\u53d6 rest \u63a5\u53e3\u4e2d\u53d1\u5e03\u7684\u6700\u65b0\u7248\u672c\u7684\u8def\u7531\u4fe1\u606f\uff0c\u5bf9\u6bd4\u7248\u672c\u53f7\uff0c\u5982\u679c\u7f51\u5173\u7684\u7248\u672c\u53f7\u4e0erest\u63a5\u53e3\u4e2d\u7684\u4e0d\u4e00\u81f4\uff0c\u5219\u83b7\u53d6\u8def\u7531\u4fe1\u606f\u540e\u66f4\u65b0\u7f51\u5173\u8def\u7531\uff0c\u8fd9\u6837\u7f51\u5173\u53d1\u5e03\u591a\u4e2a\u5b9e\u4f8b\u540e\uff0c\u90fd\u4f1a\u5355\u72ec\u7684\u53bb\u62c9\u53d6\u7ef4\u62a4\u8def\u7531\u4fe1\u606f<br \/>\n\uff084\uff09\u6574\u4f53\u67b6\u6784\u8bbe\u8ba1\u5982\u4e0b\uff1a<\/p>\n<p><!-- more --><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/SpringCloudGateway\u52a8\u6001\u8def\u7531\u67b6\u6784\u8bbe\u8ba1.png\" alt=\"Spring Cloud Gateway\u52a8\u6001\u8def\u7531\u67b6\u6784\u8bbe\u8ba1\" \/><\/p>\n<p>\u6839\u636e\u4e0a\u9762\u7684\u601d\u8def\u8fdb\u884c\u4ee3\u7801\u5b9e\u73b0\uff0c\u4e0b\u9762\u5c06\u521b\u5efa2\u4e2a\u9879\u76ee\uff0c\u90fd\u8981\u6ce8\u518c\u5230eureka\u4e0a<\/p>\n<ul>\n<li><code>dynamic-route<\/code>\uff0c\u8def\u7531\u7ba1\u7406\uff0c\u7ef4\u62a4\u8def\u7531\u4fe1\u606f\uff0c\u5e76\u5b58\u50a8\u5230mysql\u4e0eredis\u4e2d<\/li>\n<li><code>gateway-dynamic-route<\/code>\uff0c\u7f51\u5173\uff0c\u901a\u8fc7rest\u63a5\u53e3\u5b9a\u65f6\u62c9\u53d6\u6700\u65b0\u8def\u7531\u4fe1\u606f\u5e76\u66f4\u65b0\u5230\u7f51\u5173\u4e2d<\/li>\n<li><code>consumer-service<\/code>\uff0c\u6d88\u8d39\u8005\u670d\u52a1\uff0c\u6d4b\u8bd5\u52a8\u6001\u8def\u7531\u914d\u7f6e\u540e\u5c06\u8bf7\u6c42\u8f6c\u53d1\u5230\u6b64\u670d\u52a1<\/li>\n<\/ul>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/gitee.com\/zhuyu1991\/spring-cloud\/tree\/master\/gateway\">https:\/\/gitee.com\/zhuyu1991\/spring-cloud\/tree\/master\/gateway<\/a><br \/>\n\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/gitee.com\/zhuyu1991\/spring-cloud\/tree\/master\/dynamic-route\">https:\/\/gitee.com\/zhuyu1991\/spring-cloud\/tree\/master\/dynamic-route<\/a><\/p>\n<h2>\u8def\u7531\u7ba1\u7406<\/h2>\n<p>\u521b\u5efa\u4e00\u4e2a\u8def\u7531\u4fe1\u606f\u7ef4\u62a4\u7684\u9879\u76ee<code>dynamic-route<\/code>\uff0c\u5b9e\u73b0\u5bf9\u8def\u7531\u4fe1\u606f\u7684\u589e\u5220\u6539\u67e5\u548c\u53d1\u5e03\u529f\u80fd\uff0c\u4fe1\u606f\u4fdd\u5b58\u5230mysql\u4e2d\uff0c\u53d1\u5e03\u540e\u4fdd\u5b58\u5230redis\uff0c\u5bf9\u5916\u63d0\u4f9b\u8def\u7531\u6570\u636e\u65f6\u8fd4\u56deredis\u4e2d\u7684\u8def\u7531\u4fe1\u606f\uff08\u4f7f\u7528\u7f13\u5b58\u6765\u5e94\u5bf9\u7f51\u5173\u5b9a\u65f6\u4efb\u52a1\u8bfb\u8bf7\u6c42\uff09<\/p>\n<p>\u67092\u5f20\u8868\uff0c\u8def\u7531\u4fe1\u606f\u8868\u4e0e\u7248\u672c\u53d1\u5e03\u8868\uff0c\u8868\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-sql\">-- ----------------------------\n-- Table structure for gateway_routes\n-- ----------------------------\nDROP TABLE IF EXISTS `gateway_routes`;\nCREATE TABLE `gateway_routes` (\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `route_id` varchar(64) DEFAULT NULL COMMENT &#039;\u8def\u7531id&#039;,\n  `route_uri` varchar(128) DEFAULT NULL COMMENT &#039;\u8f6c\u53d1\u76ee\u6807uri&#039;,\n  `route_order` int(11) DEFAULT NULL COMMENT &#039;\u8def\u7531\u6267\u884c\u987a\u5e8f&#039;,\n  `predicates` text COMMENT &#039;\u65ad\u8a00JSON\u5b57\u7b26\u4e32\u96c6\u5408&#039;,\n  `filters` text COMMENT &#039;\u8fc7\u6ee4\u5668JSON\u5b57\u7b26\u4e32\u96c6\u5408&#039;,\n  `is_ebl` tinyint(1) DEFAULT NULL COMMENT &#039;\u662f\u5426\u542f\u7528&#039;,\n  `is_del` tinyint(1) DEFAULT NULL COMMENT &#039;\u662f\u5426\u5220\u9664&#039;,\n  `create_time` datetime DEFAULT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,\n  `update_time` datetime DEFAULT NULL COMMENT &#039;\u4fee\u6539\u65f6\u95f4&#039;,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;\n\n-- ----------------------------\n-- Table structure for dynamic_version\n-- ----------------------------\nDROP TABLE IF EXISTS `dynamic_version`;\nCREATE TABLE `dynamic_version` (\n  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#039;\u4e3b\u952e\u3001\u81ea\u52a8\u589e\u957f\u3001\u7248\u672c\u53f7&#039;,\n  `create_time` datetime DEFAULT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;<\/code><\/pre>\n<p>\u8def\u7531\u5217\u8868\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9600\/gateway-routes\/list\">http:\/\/localhost:9600\/gateway-routes\/list<\/a><br \/>\n\u6dfb\u52a0\u8def\u7531\u4fe1\u606f\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9600\/gateway-routes\/edit?id=2\">http:\/\/localhost:9600\/gateway-routes\/edit?id=2<\/a><br \/>\n\u83b7\u53d6\u7248\u672c\u4fe1\u606f\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9600\/version\/lastVersion\">http:\/\/localhost:9600\/version\/lastVersion<\/a><br \/>\n\u83b7\u53d6\u8def\u7531\u4fe1\u606f\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9600\/gateway-routes\/routes\">http:\/\/localhost:9600\/gateway-routes\/routes<\/a><\/p>\n<p>\u7f51\u5173\u5148\u83b7\u53d6\u7248\u672c\u53f7\uff0c\u4e0e\u672c\u5730\u7248\u672c\u53f7\u5bf9\u6bd4\uff0c\u5982\u4e0d\u4e00\u81f4\u5219\u901a\u8fc7\u6b64\u63a5\u53e3\u62c9\u53d6\u8def\u7531\u4fe1\u606f<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/SpringCloudGateway\u52a8\u6001\u8def\u7531\u7ba1\u7406.png\" alt=\"Spring Cloud Gateway\u52a8\u6001\u8def\u7531\u7ba1\u7406\" \/><\/p>\n<h2>\u7f51\u5173\u9879\u76ee<\/h2>\n<p>\u91cd\u70b9\u662f\u7f51\u5173\u9879\u76ee\uff0c\u521b\u5efa gateway-dynamic-route \u9879\u76ee\uff0c\u7f51\u5173\u542f\u52a8\u65f6\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u7248\u672c\u53f7\u4e3a0\uff0c\u901a\u8fc7\u5b9a\u65f6\u4efb\u52a1\u6bcf60\u79d2\u62c9\u53d6\u4e00\u6b21\u8fdc\u7a0b\u8def\u7531\u9879\u76ee\u63d0\u4f9b\u6700\u65b0\u7248\u672c\u53f7\uff0c\u4e0e\u7f51\u5173\u7684\u7248\u672c\u53f7\u5bf9\u6bd4\uff0c\u5982\u4e0d\u4e00\u81f4\uff0c\u5219\u62c9\u53d6\u8fdc\u7a0b\u8def\u7531\u9879\u76ee\u6700\u65b0\u7684\u8def\u7531\u4fe1\u606f\uff0c\u66f4\u65b0\u5230\u7f51\u5173\u8def\u7531\u4e0a\u53bb\uff0c\u540c\u65f6\u628a\u672c\u5730\u7248\u672c\u53f7\u8986\u76d6\u4e3a\u6700\u65b0\u7684\u7248\u672c\u53f7<\/p>\n<p>\uff081\uff09\u542f\u52a8\u5b9a\u65f6\u4efb\u52a1\uff0c\u6ce8\u518c\u5230erueka\uff0c\u6dfb\u52a0RestTemplate Bean\u4e14\u4ee5\u8d1f\u8f7d\u5747\u8861\u5f62\u5f0f\u8bbf\u95ee\u8def\u7531\u9879\u76ee<\/p>\n<pre><code class=\"language-java\">@EnableScheduling\n@EnableDiscoveryClient\n@SpringBootApplication\npublic class GatewayDynamicRouteApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(GatewayDynamicRouteApplication.class, args);\n    }\n\n    @Bean\n    @LoadBalanced\n    public RestTemplate restTemplate() {\n        return new RestTemplate();\n    }\n}<\/code><\/pre>\n<p>\uff082\uff09\u5b9a\u65f6\u4efb\u52a1\u5b9e\u73b0\u7c7b<\/p>\n<pre><code class=\"language-java\">\/**\n * \u5b9a\u65f6\u4efb\u52a1\uff0c\u62c9\u53d6\u8def\u7531\u4fe1\u606f\n * \u8def\u7531\u4fe1\u606f\u7531\u8def\u7531\u9879\u76ee\u5355\u72ec\u7ef4\u62a4\n *\/\n@Component\npublic class DynamicRouteScheduling {\n\n    @Autowired private RestTemplate restTemplate;\n    @Autowired private DynamicRouteService dynamicRouteService;  \/\/\u52a8\u6001\u8def\u7531\u5b9e\u73b0\u7c7b\uff0c\u4e0e\u524d\u7bc7\u535a\u5ba2\u4e2d\u7684\u5b9e\u73b0\u7c7b\u4ee3\u7801\u662f\u4e00\u6837\u7684\n\n    private static final SimpleDateFormat dateFormat = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;);\n    private static final String dynamicRouteServerName = &quot;dynamic-route-service&quot;;\n\n    \/\/\u53d1\u5e03\u8def\u7531\u4fe1\u606f\u7684\u7248\u672c\u53f7\n    private static Long versionId = 0L;\n\n    \/\/\u6bcf60\u79d2\u4e2d\u6267\u884c\u4e00\u6b21\n    \/\/\u5982\u679c\u7248\u672c\u53f7\u4e0d\u76f8\u7b49\u5219\u83b7\u53d6\u6700\u65b0\u8def\u7531\u4fe1\u606f\u5e76\u66f4\u65b0\u7f51\u5173\u8def\u7531\n    @Scheduled(cron = &quot;*\/60 * * * * ?&quot;)\n    public void getDynamicRouteInfo() {\n        try {\n            System.out.println(&quot;\u62c9\u53d6\u65f6\u95f4:&quot; + dateFormat.format(new Date()));\n            \/\/\u5148\u62c9\u53d6\u7248\u672c\u4fe1\u606f\uff0c\u5982\u679c\u7248\u672c\u53f7\u4e0d\u60f3\u7b49\u5219\u66f4\u65b0\u8def\u7531\n            Long resultVersionId = restTemplate.getForObject(&quot;http:\/\/&quot;+ dynamicRouteServerName + &quot;\/version\/lastVersion&quot;, Long.class);\n            System.out.println(&quot;\u8def\u7531\u7248\u672c\u4fe1\u606f\uff1a\u672c\u5730\u7248\u672c\u53f7\uff1a&quot; + versionId + &quot;\uff0c\u8fdc\u7a0b\u7248\u672c\u53f7\uff1a&quot; + resultVersionId);\n            if(resultVersionId != null &amp;&amp; versionId != resultVersionId) {\n                System.out.println(&quot;\u5f00\u59cb\u62c9\u53d6\u8def\u7531\u4fe1\u606f......&quot;);\n                String resultRoutes = restTemplate.getForObject(&quot;http:\/\/&quot;+ dynamicRouteServerName + &quot;\/gateway-routes\/routes&quot;, String.class);\n                System.out.println(&quot;\u8def\u7531\u4fe1\u606f\u4e3a\uff1a&quot; + resultRoutes);\n                if (!StringUtils.isEmpty(resultRoutes)) {\n                    List&lt;GatewayRouteDefinition&gt; list = JSON.parseArray(resultRoutes, GatewayRouteDefinition.class);\n                    for (GatewayRouteDefinition definition : list) {\n                        \/\/\u66f4\u65b0\u8def\u7531\n                        RouteDefinition routeDefinition = assembleRouteDefinition(definition);\n                        dynamicRouteService.update(routeDefinition);\n                    }\n                    versionId = resultVersionId;\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    \/\/\u628a\u524d\u7aef\u4f20\u9012\u7684\u53c2\u6570\u8f6c\u6362\u6210\u8def\u7531\u5bf9\u8c61\n    private RouteDefinition assembleRouteDefinition(GatewayRouteDefinition gwdefinition) {\n        RouteDefinition definition = new RouteDefinition();\n        definition.setId(gwdefinition.getId());\n        definition.setOrder(gwdefinition.getOrder());\n\n        \/\/\u8bbe\u7f6e\u65ad\u8a00\n        List&lt;PredicateDefinition&gt; pdList=new ArrayList&lt;&gt;();\n        List&lt;GatewayPredicateDefinition&gt; gatewayPredicateDefinitionList=gwdefinition.getPredicates();\n        for (GatewayPredicateDefinition gpDefinition: gatewayPredicateDefinitionList) {\n            PredicateDefinition predicate = new PredicateDefinition();\n            predicate.setArgs(gpDefinition.getArgs());\n            predicate.setName(gpDefinition.getName());\n            pdList.add(predicate);\n        }\n        definition.setPredicates(pdList);\n\n        \/\/\u8bbe\u7f6e\u8fc7\u6ee4\u5668\n        List&lt;FilterDefinition&gt; filters = new ArrayList();\n        List&lt;GatewayFilterDefinition&gt; gatewayFilters = gwdefinition.getFilters();\n        for (GatewayFilterDefinition filterDefinition : gatewayFilters) {\n            FilterDefinition filter = new FilterDefinition();\n            filter.setName(filterDefinition.getName());\n            filter.setArgs(filterDefinition.getArgs());\n            filters.add(filter);\n        }\n        definition.setFilters(filters);\n\n        URI uri = null;\n        if (gwdefinition.getUri().startsWith(&quot;http&quot;)) {\n            uri = UriComponentsBuilder.fromHttpUrl(gwdefinition.getUri()).build().toUri();\n        } else {\n            uri = URI.create(gwdefinition.getUri());\n        }\n        definition.setUri(uri);\n        return definition;\n    }\n}<\/code><\/pre>\n<p>\uff083\uff09\u7f51\u5173\u63d0\u4f9b\u83b7\u53d6\u6240\u6709\u8def\u7531\u4fe1\u606f\u7684Controller<\/p>\n<pre><code class=\"language-java\">\/**\n * \u67e5\u8be2\u7f51\u5173\u7684\u8def\u7531\u4fe1\u606f\n *\/\n@RestController\n@RequestMapping(&quot;\/route&quot;)\npublic class DynamicRouteController {\n\n    @Autowired\n    private RouteDefinitionLocator routeDefinitionLocator;\n\n    \/\/\u83b7\u53d6\u7f51\u5173\u6240\u6709\u7684\u8def\u7531\u4fe1\u606f\n    @RequestMapping(&quot;\/routes&quot;)\n    public Flux&lt;RouteDefinition&gt; getRouteDefinitions() {\n        return routeDefinitionLocator.getRouteDefinitions();\n    }\n}<\/code><\/pre>\n<p>\uff084\uff09\u542f\u52a8<code>eureka<\/code>\u3001<code>dynamic-route<\/code>\u3001<code>gateway-dynamic-route<\/code>\u3001<code>consumer-service<\/code><\/p>\n<p>\uff085\uff09\u901a\u8fc7<code>dynamic-route<\/code>\u9879\u76ee\u65b0\u589e\u4e00\u6761\u8def\u7531\u4fe1\u606f\uff0c\u8def\u7531\u7684 uri \u662f<code>consumer-service<\/code>\uff0c\u4e14\u53d1\u5e03\u8def\u7531<\/p>\n<p>\u53d1\u5e03\u8def\u7531\u65f6\uff0c\u4f1a\u5c06\u7248\u672c\u8868\u6700\u65b0\u7684\u7248\u672c\u53f7\u4e0e\u8def\u7531\u4fe1\u606f\u6dfb\u52a0\u5230redis\u4e2d\uff0c\u7f51\u5173\u5b9a\u65f6\u83b7\u53d6\u7248\u672c\u4fe1\u606f\u4e0e\u8def\u7531\u4fe1\u606f\u90fd\u662f\u5148\u4eceredis\u4e2d\u53d6\u51fa\u6765\u7684<\/p>\n<p>\uff086\uff09\u56e0\u7f51\u5173\u6ca1\u6709\u914d\u7f6e\u8def\u7531\u4fe1\u606f\uff0c\u53ef\u901a\u8fc7 <a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9999\/route\/routes\">http:\/\/localhost:9999\/route\/routes<\/a> \u83b7\u53d6\u6240\u6709\u8def\u7531\u4fe1\u606f\uff0c\u6b64\u65f6\u6709\u4e24\u6761\u8def\u7531\u4fe1\u606f\uff0c\u662f\u7f51\u5173\u4eceeureka\u4e0a\u62c9\u4e0b\u6765\u7684\u9ed8\u8ba4\u7684\u8def\u7531\u4fe1\u606f\uff0c\u4e0d\u662f\u914d\u7f6e\u7684\u8def\u7531\u4fe1\u606f<\/p>\n<p>\uff087\uff09\u7b49\u5f8560\u79d2\u540e\uff0c\u7f51\u5173\u901a\u8fc7 RestTemplate \u62c9\u53d6<code>dynamic-route<\/code>\u9879\u76ee\u7684\u6700\u65b0\u7248\u672c\u53f7\uff0c\u53d1\u73b0\u4e0d\u4e00\u81f4\uff0c\u5219\u62c9\u53d6\u6700\u65b0\u8def\u7531\u4fe1\u606f\uff0c\u5e76\u66f4\u65b0\u5230\u7f51\u5173\u8def\u7531\u4e2d<\/p>\n<p>\uff088\uff09\u901a\u8fc7\u7f51\u5173\u8bbf\u95ee<code>consumer-service<\/code>\uff0c\u9a8c\u8bc1\u8def\u7531\u4fe1\u606f\u662f\u5426\u5df2\u66f4\u65b0\u5230\u7f51\u5173\u4e2d\uff0c\u8bbf\u95ee\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9999\/appblog\/hello?name=joe\">http:\/\/localhost:9999\/appblog\/hello?name=joe<\/a><\/p>\n<p>\uff089\uff09\u518d\u6b21\u67e5\u770b\u6240\u6709\u8def\u7531\u4fe1\u606f\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9999\/route\/routes\">http:\/\/localhost:9999\/route\/routes<\/a> \uff0c\u53ef\u770b\u5230<code>consumer-service<\/code>\u5df2\u88ab\u8bbe\u7f6e\u5230\u7f51\u5173\u8def\u7531\u4e2d\u4e86<\/p>\n<p>\uff0810\uff09\u6bcf\u969460\u79d2\u518d\u6b21\u5bf9\u6bd4\u7248\u672c\u53f7\uff0c\u5f53\u6709\u65b0\u7684\u7248\u672c\u53f7\u53d1\u5e03\u540e\uff0c\u5c31\u4f1a\u62c9\u53d6\u7ef4\u62a4\u7684\u8def\u7531\u4fe1\u606f\uff0c\u6ca1\u6709\u5219\u7f51\u5173\u4e0d\u4f1a\u66f4\u65b0\u8def\u7531<\/p>\n<p>\uff0811\uff09\u4fee\u6539\u4e00\u4e0b\u8def\u7531\u4fe1\u606f\uff0c\u628a\u65ad\u8a00<code>Path=\/appblog\/**<\/code>\uff0c\u6539\u4e3a<code>Path=\/consumer\/**<\/code>\uff0c\u5e76\u53d1\u5e03\uff0c\u9694\u4e8660\u79d2\u540e\uff0c\u7f51\u5173\u7684\u63a7\u5236\u53f0\u62c9\u53d6\u5230\u6700\u65b0\u7684\u8def\u7531\u4fe1\u606f<\/p>\n<p>\uff0812\uff09\u6b64\u65f6\u8bbf\u95ee <a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9999\/appblog\/hello?name=joe\">http:\/\/localhost:9999\/appblog\/hello?name=joe<\/a> \u62a5\u9519\uff0c\u56e0\u4e3a\u8def\u7531\u65ad\u8a00path\u88ab\u66f4\u6539\u4e86\u8def\u7531\u4e0d\u5230<\/p>\n<p>\uff0813\uff09\u9700\u8981\u901a\u8fc7 <a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:9999\/consumer\/hello?name=joe\">http:\/\/localhost:9999\/consumer\/hello?name=joe<\/a> \u8bbf\u95ee\uff0c\u6b63\u5e38\u8fd4\u56de<\/p>\n<blockquote>\n<p>\u6539\u8fdb\uff1a\u53ef\u5c06\u5b9a\u65f6\u4efb\u52a1\u6539\u4e3aMQ\u53d1\u9001\u3001\u4e3b\u52a8\u8bf7\u6c42\u63a8\u9001\u3001\u957f\u8fde\u63a5\u8bf7\u6c42\u7b49\u65b9\u6848<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6848\u7b80\u4ecb \uff081\uff09\u521b\u5efa\u4e00\u4e2a\u8def\u7531\u4fe1\u606f\u7ef4\u62a4\u7684\u9879\u76ee\uff08dynamic-route\uff09\uff0c\u5b9e\u73b0\u589e\u5220\u6539\u67e5\u8def\u7531\u4fe1\u606f\u5230mysql \uff08 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[439],"class_list":["post-1954","post","type-post","status-publish","format-standard","hentry","category-spring-cloud","tag-spring-cloud-gateway"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1954"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1954\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}